[CF#250 Div.2 D]The Child and Zoo(并查集)
题目:http://codeforces.com/problemset/problem/437/D
题意:有n个点,m条边的无向图,保证所有点都能互通,n,m<=10^5
每个点都有权值,每条边的权值定义为这条边连接两点的权值中的最小值。
f(p,q)表示p到q的路径中边权的最小值,如果有多条路经,就取每条路径最小值中的最小值
要求的就是对于所有1<=p<=n,1<=q<=n,p≠q,f(p,q)的平均值
分析:
刚开始是想考虑每条边对总和的贡献,结果没想通。
一个很巧的办法就是贪心的想法,将所有的边按照从大到小排序,然后加入图中,类似Kruskal算法,易得每次加的边对总和的贡献就是2*两个区域节点数的乘积。这个用带权并查集弄一下就行。
[CF#250 Div.2 D]The Child and Zoo(并查集)的更多相关文章
- 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/ ...
- Codeforces Round #250 (Div. 2) D. The Child and Zoo 并查集
D. The Child and Zoo time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces 437 D. The Child and Zoo 并查集
题目链接:D. The Child and Zoo 题意: 题意比较难懂,是指给出n个点并给出这些点的权值,再给出m条边.每条边的权值为该条路连接的两个区中权值较小的一个.如果两个区没有直接连接,那么 ...
- Codeforces Round #360 (Div. 1) D. Dividing Kingdom II 暴力并查集
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time a ...
- CF思维联系--CodeForces - 218C E - Ice Skating (并查集)
题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his ...
- 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 ...
- 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/ ...
- Codeforces Round #250 (Div. 2)—A. The Child and Homework
好题啊,被HACK了.曾经做题都是人数越来越多.这次比赛 PASS人数 从2000直掉 1000人 被HACK 1000多人! ! ! ! 没见过的科技啊 1 2 4 8 这组数 被黑的 ...
- Codeforces Round #250 (Div. 1) D. The Child and Sequence(线段树)
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...
随机推荐
- MySQL入门(二)
一 MySQL概述 MySQL是一个很受欢迎的开源数据库,当我从Oracle转来做MySQL的时候,感觉最深刻的一点就是,这家伙居然是Server和Storage分开的!而且更不能忍的是,它竟然是插件 ...
- 查看Android支持的硬解码信息
通过/system/etc/media_codecs.xml可以确定当前设备支持哪些硬解码.通过/system/etc/media_profiles.xml可以知道设备支持的具体profile和lev ...
- wc
$wc [-lwc] filename统计的文件的信息,缺省参数会按照lwc的顺序输出全部三种信息 -l统计文件的行数 -w统计文件的字数,字以空格和换行符分隔 -c统计文件的字符数,包括换行等 例子 ...
- node.js表单——formidable
node处理表单请求,需要用到formidable包.安装formidable包的命令如下: npm install formidable 安装package的路径分为两种,一种是本地目录,一种是全局 ...
- tar 解压出错
今天下载了一个Linux内核文件,解压的时候出现了这样的错误: gzip: stdin: unexpected end of file tar: Unexpected EOF in archive t ...
- C++ 中 typename
声明template参数时, 前缀关键字class和typename可以互换; 使用关键字typename标识嵌套从属类型名称, 但不需在基类列表和成员初始化列表内使用. 从属名称(dependent ...
- HADOOP HDFS的设计
Hadoop提供的对其HDFS上的数据的处理方式,有以下几种, 1 批处理,mapreduce 2 实时处理:apache storm, spark streaming , ibm streams 3 ...
- 【转载】阎焱:90后创业是扯淡 大量O2O和P2P公司濒临倒闭
真正创业成功的大部分是年龄在30岁到38岁之间,很多90后基本什么都不懂.从历史来看,在这样的人口大国,集体性行为,无论是政治的还是经济的,基本都是导致灾难性后果. 10月14日消息,赛富基金创始首席 ...
- c++关于析构的那点小事(个人吐槽向
#include<iostream> using namespace std; class test { int *i; public: test(int n) { i = new int ...
- Codeforces Round #371 (Div. 2) C. Sonya and Queries[Map|二进制]
C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard ...