题目: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(并查集)的更多相关文章

  1. 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/ ...

  2. 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 ...

  3. Codeforces 437 D. The Child and Zoo 并查集

    题目链接:D. The Child and Zoo 题意: 题意比较难懂,是指给出n个点并给出这些点的权值,再给出m条边.每条边的权值为该条路连接的两个区中权值较小的一个.如果两个区没有直接连接,那么 ...

  4. 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 ...

  5. CF思维联系--CodeForces - 218C E - Ice Skating (并查集)

    题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his ...

  6. 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 ...

  7. 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/ ...

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

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

  9. 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 ...

随机推荐

  1. mysql自动备份维护shell脚本 (copy)

    #!/bin/bash #Mysql 自动备份 压缩并上传到 指定ftp #设想每天凌晨3点备份mysql #编辑crontab配置文件 # * * * backupmysql.sh #压缩并以&qu ...

  2. LeetCode #303. Range Sum Query

    问题: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclu ...

  3. addrinfo 结构

    typedef struct addrinfo {int             ai_flags;int            ai_family;int             ai_sockty ...

  4. discuz mysqli_connect() 不支持 advice_mysqli_connect

      看网友的解决方案是:下面2行去掉注释 ? 1 2 ;extension=php_mysql.dll ;extension=php_mysqli.dl 尝试修改 ? 1 #vi /etc/php.i ...

  5. java运算优先级

    列号 符号 名称 结合性(与操作数) 目数 说明 1 . 点 从左到右 双目 ( ) 圆括号 从左到右   [ ] 方括号 从左到右   2 + 正号 从右到左 单目 - 负号 从右到左 单目 ++ ...

  6. 浅谈 Linux 内核无线子系统

    浅谈 Linux 内核无线子系统 本文目录 1. 全局概览 2. 模块间接口 3. 数据路径与管理路径 4. 数据包是如何被发送? 5. 谈谈管理路径 6. 数据包又是如何被接收? 7. 总结一下 L ...

  7. [uwsgi] no request plugin is loaded, you will not be able to manage requests.

    Problem: *** Operational MODE: preforking+threaded no app loaded. going in full dynamic mode uWSGI i ...

  8. 以最简单的登录为例,诠释JS面向对象的简单实例

    JavaScript,是前端开发人员必须会的一门技术,从JS演变出来的有很多框架,先说说几个热门的框架吧: JQuery:这个技术必须会,如果不会,那一定要会查api,知道怎么写,要看得懂英文文档,这 ...

  9. ArrayList如何实现线程安全

    一:使用synchronized关键字,这个大家应该都很熟悉了,不解释了: 二:使用Collections.synchronizedList();使用方法如下: 假如你创建的代码如下:List< ...

  10. AppStore ipa (苹果内购)笔记

    内购示意图 准备条件 苹果的开发者证书,已经为应用启用App内购,并在Xcode更新配置文件 itunes store设置 itunes中创建App及其它设置 参考:iOS应用程序内购/内付费(一)  ...