这几次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. 【Spring MVC】 - @ModelAttribute使用

    @ModelAttribute一个具有如下三个作用: ①绑定请求参数到命令对象:放在功能处理方法的入参上时,用于将多个请求参数绑定到一个命令对象,从而简化绑 定流程,而且自动暴露为模型数据用于视图页面 ...

  2. 转,如果linux不能用yum安装asterisk时,可以库参照以下办法添加asterisk仓库

    LinuxCentOSRedHat Installing a binary distribution of Asterisk makes it easier to maintain your syst ...

  3. Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中。

    从浏览器中创建 XMLHttpRequests 从 node.js 创建 http 请求 支持 Promise API 拦截请求和响应 转换请求数据和响应数据 取消请求 自动转换 JSON 数据 客户 ...

  4. DLL的远程注入技术

    DLL的远程注入技术是目前Win32病毒广泛使用的一种技术.使用这种技术的病毒体通常位于一个DLL中,在系统启动的时候,一个EXE程序会将这个DLL加载至某些系统进程(如Explorer.exe)中运 ...

  5. 网络应用软件结构-----CS与BS结构(网络基本知识小结)

    1.网络的大致结构 2.网络编程 通过直接或间接地使用网络通讯的协议实现计算机与计算机之间的通讯.在TCP/IP协议层主要麦网络主机的定位,数据传输的路由,由IP地址可以唯一地确定Internet上的 ...

  6. 1.js 模拟a标签打开新网页

    var el = document.createElement("a"); document.body.appendChild(el); el.href = url; //url  ...

  7. %02d %03d

    strTemp.Format("%02d",m_unEditPosition); %02d 输出两位整数,不足两位的前面加0,比如05,06…… %03d 输出三位整数,不足两位的 ...

  8. Android 常用adb shell 命令(转)

    调试Android程序有时需要adb shell 命令,adb全称Android Debug Bridge ,就是起到调试桥的作用. 通过adb我们可以在Eclipse中通过DDMS来调试Androi ...

  9. 01.课程介绍 & 02.最小可行化产品MVP

    01.课程介绍 02.最小可行化产品MVP 产品开发过程 最小化和可用之间找到一个平衡点

  10. python接口自动化(三十七)-封装与调用--读取excel 数据(详解)

    简介 在进行软件接口测试或设计自动化测试框架时,一个不比可避免的过程就是: 参数化,在利用python进行自动化测试开发时,通常会使用excel来做数据管理,利用xlrd.xlwt开源包来读写exce ...