这几次CF都挺惨。。

A

没条边权设为两端点的最小点权,最后加起来。

数组开小,WA一次

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 2010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int v[N];
int a[N];
int main()
{
int i,j,n,m;
cin>>n>>m;
for(i = ; i <= n; i++)
scanf("%d",&v[i]);
for(i = ; i <= m ;i++)
{
int x,y;
scanf("%d%d",&x,&y);
a[i] = min(v[x],v[y]);
}
int ans = ;
for(i = ;i <= m ;i++)
{
ans+=a[i];
}
cout<<ans<<endl;
return ;
}

B

以点权排序,删除某个点之后,哪些比它点权大的不再连通就说明那些点对的p值肯定为他的点权,想到了这点,却忘了并差集可以使不连通块连通。

做法:给每个边一个边权,为两端点的最小点权,以边权从大到小排序,依次进行合并,若当前不连通这以这个边权*块1的数量*块2的数量

排序的时候 错把m写成n wa一次。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int fa[N],res[N],a[N];
int find(int x)
{
if(fa[x]!=x)
{
fa[x] = find(fa[x]);
return fa[x];
}
return x;
}
struct node
{
int u,v,w;
}p[N];
bool cmp(node a,node b)
{
return a.w>b.w;
}
int main()
{
int n,m,i;
cin>>n>>m;
for(i = ; i <=n; i++)
{
scanf("%d",&a[i]);
fa[i] = i;
res[i] = ;
}
for(i = ;i <=m ;i++)
{
scanf("%d%d",&p[i].u,&p[i].v);
p[i].w = min(a[p[i].u],a[p[i].v]);
}
sort(p+,p+m+,cmp);
double ans = ;
for(i = ; i <= m ;i++)
{
int tx = find(p[i].u),ty = find(p[i].v);
if(tx!=ty)
{
fa[tx] = ty;
ans+=(double)p[i].w*res[tx]*res[ty];
res[ty]+=res[tx];
// res[tx] = 0;
}
}
printf("%.6f\n",(ans*)/(n*1.0*(n-)));
return ;
}

D

没有比这题更悲伤了,最后20分钟看,十几分钟敲完,最后十几秒交上,wa了,,发现少写了个lm。。。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100010
#define LL __int64
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL s[N<<],lm[N<<];
int a[N];
void up(int w)
{
s[w] = s[w<<]+s[w<<|];
lm[w] = max(lm[w<<],lm[w<<|]);
}
void build(int l,int r,int w)
{
if(l==r)
{
s[w] = a[l];
lm[w] = a[l];
return ;
}
int m = (l+r)>>;
build(l,m,w<<);
build(m+,r,w<<|);
up(w);
}
LL query(int a,int b,int l,int r,int w)
{
if(a<=l&&b>=r)
{
return s[w];
}
int m = (l+r)>>;
LL res=;
if(a<=m) res+=query(a,b,l,m,w<<);
if(b>m) res+=query(a,b,m+,r,w<<|);
return res;
}
void update(int p,int d,int l,int r,int w)
{
if(l==r)
{
s[w] = lm[w] = d;
return ;
}
int m = (l+r)>>;
if(p<=m) update(p,d,l,m,w<<);
else update(p,d,m+,r,w<<|);
up(w);
}
void find(int a,int b,int mod,int l,int r,int w)
{
if(a<=l&&b>=r)
{
if(lm[w] < mod)
return ;
if(l==r)
{
int k = s[w]%mod;
s[w] = lm[w] = k;
return ;
}
int m = (l+r)>>;
find(a,b,mod,l,m,w<<);
find(a,b,mod,m+,r,w<<|);
up(w);
return ;
}
int m = (l+r)>>;
if(a<=m) find(a,b,mod,l,m,w<<);
if(b>m) find(a,b,mod,m+,r,w<<|);
up(w);
}
int main()
{
int n,m,i;
cin>>n>>m;
for(i = ; i <=n; i++)
scanf("%d",&a[i]);
build(,n,);
int l,r,x,k;
while(m--)
{
scanf("%d",&k);
if(k==)
{
scanf("%d%d",&l,&r);
LL k = query(l,r,,n,);
printf("%I64d\n",k);
}
else if(k==)
{
scanf("%d%d%d",&l,&r,&x);
find(l,r,x,,n,);
}
else
{
scanf("%d%d",&k,&x);
update(k,x,,n,);
}
}
return ;
}

小小总结下:貌似每题都有注意不到的地方,还各不相同,说明不是我记忆力的问题,是注意力的问题,有空多刷几场TC,我印象中TC没有不出问题的时候,所以我现在依旧安稳的呆在DIV2。

发现学的多就会想得多,B题一直想在强连通分量上,心里觉得图的东西不是特别会,隐隐约约的觉得应该做不出来了,可又发现过的人好多,应该是会的,比赛的时候想的太多了,思路没有前行在正确的方向,注意力不能完全集中在题上。

Codeforces Round #250 (Div. 1)的更多相关文章

  1. Codeforces Round #250 (Div. 2)A(英语学习)

    链接:http://codeforces.com/contest/437/problem/A A. The Child and Homework time limit per test 1 secon ...

  2. Codeforces Round #250 (Div. 1) D. The Child and Sequence (线段树)

    题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x, ...

  3. Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间取摸

    D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  4. Codeforces Round #250 (Div. 1) B. The Child and Zoo 并查集

    B. The Child and Zoo Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...

  5. Codeforces Round #250 (Div. 1) A. The Child and Toy 水题

    A. The Child and Toy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...

  6. Codeforces Round #250 (Div. 2) A. The Child and Homework

    注意题目长度不能考虑前缀,而且如果即存在一个选项的长度的两倍小于其他所有选项的长度,也存在一个选项的长度大于其他选项长度的两倍,则答案不是一个好的选择,只能选择C. #include <iost ...

  7. Codeforces Round #250 (Div. 2) C、The Child and Toy

    注意此题,每一个部分都有一个能量值v[i],他移除第i部分所需的能量是v[f[1]]+v[f[2]]+...+v[f[k]],其中f[1],f[2],...,f[k]是与i直接相连(且还未被移除)的部 ...

  8. Codeforces Round #250 (Div. 2)

    感觉不会再爱了,呜呜! A题原来HACK这么多!很多人跟我一样掉坑了! If there is some choice whose description at least twice shorter ...

  9. Codeforces Round #250 (Div. 2)——The Child and Set

    题目链接 题意: 给定goal和limit,求1-limit中的若干个数,每一个数最多出现一次,且这些数的lowbit()值之和等于goal,假设存在这种一些数,输出个数和每一个数:否则-1 分析: ...

  10. Codeforces Round #250 (Div. 2)—A. The Child and Homework

         好题啊,被HACK了.曾经做题都是人数越来越多.这次比赛 PASS人数 从2000直掉 1000人  被HACK  1000多人! ! ! ! 没见过的科技啊 1 2 4 8 这组数 被黑的 ...

随机推荐

  1. 从Inception v1,v2,v3,v4,RexNeXt到Xception再到MobileNets,ShuffleNet,MobileNetV2

    from:https://blog.csdn.net/qq_14845119/article/details/73648100 Inception v1的网络,主要提出了Inceptionmodule ...

  2. 数据库之Oracle

    数据库之Oracle 一. 用户的管理 1. 用户就是好比公司的某个人,而权限是这个人能在公司做什么,他的角色就是说明他的职位. 2. 用户的权限分为: 系统权限:对别的用户的管理操作. 对象权限:对 ...

  3. 【python】string functions

    1.str.replace(word0,word1)  ##用word1替换str中所有的word0 >>> 'tea for too'.replace('too', 'two') ...

  4. java并发之阻塞队列LinkedBlockingQueue与ArrayBlockingQueue

    Java中阻塞队列接口BlockingQueue继承自Queue接口,并提供put.take阻塞方法.两个主要的阻塞类实现是ArrayBlockingQueue和LinkedBlockingQueue ...

  5. mysql分区表之四:分区表性能

    一,      分区概念  分区允许根据指定的规则,跨文件系统分配单个表的多个部分.表的不同部分在不同的位置被存储为单独的表.MySQL从5.1.3开始支持Partition. 分区和手动分表对比 手 ...

  6. web集群时代

    随着业务的不断增加,我们的单台服务器承受不住需求,那么我们就需要对此进行伸缩,有两种维度,一种是纵向的也就是增大该台服务器的硬件,再者就是加新服务器与之前的机器组成集群对外提供服务,我们都知道前者是有 ...

  7. 【223】◀▶ IDL HDF 文件操作说明

    参考:I/O - HDF Routines —— HDF 操作函数 01   HDF_SD_START 打开一个 SDS 模式的 HDF 文件. 02   HDF_SD_END 关闭一个 SDS 模式 ...

  8. (转)data Table的用法大全

    jqyery dataTable 基本用法 一:官方网站:[http://www.datatables.net/] 二:基本使用:[http://www.guoxk.com/node/jquery-d ...

  9. RetHad6.7离线通过.rpm安装

    必须有RetHad6.7系统的.ios镜像文件,我们需要的.rpm都在镜像的Packages里面,针对不能联网的,并且也适用与CentOS系统 1. 查看版本号 参考我的博客 https://www. ...

  10. myeclipse同时部署两个项目-permgen space

    黑色头发:http://heisetoufa.iteye.com/ 使用myeclipse启动两个SSH2的部署在tomcat6下的项目报出java.lang.OutOfMemoryError: Pe ...