hdu_5723_Abandoned country(最小生成树)】的更多相关文章

题目链接:hdu_5723_Abandoned country 题意: 让你求最小生成树的花费,然后求任给两点的期望路程 题解: 最小生成树大家都会求,Kruskal这里要改改,因为后面要求任意两点的期望路程,我们这里Kruskal 记录下最小生成树的边,然后通过DFS把树建出来,最后找每条边经过了多少次,然后乘上对应的组合,比如样列,第一条边权为1的边,这条边左边只有一个节点,右边有3个节点,那么这条边就会经过3次,所以这条边的贡献就是1(左边点个数)*3(右边点个数)*1(边权),依次类推,…
Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 4477    Accepted Submission(s): 1124 Problem Description An abandoned country has n(n≤100000) villages which are numbered from 1…
Abandoned country 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5723 Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) ro…
Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3006    Accepted Submission(s): 346 Problem Description An abandoned country has n(n≤100000) villages which are numbered from 1…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5723 n个村庄m条双向路,从中要选一些路重建使得村庄直接或间接相连且花费最少,这个问题就是很明显的求最小生成树,由于边权各不相同,所以最小生成树唯一. 然后,在这个最小生成树的基础上,求各个路径的最小期望和(推导出 期望 = 所有村庄中任意两个村庄距离之和 / 村庄对数). 最小生成树很好求(边权从小到大,并查集一下就好了). 然后求以上基础村庄中任意两个村庄距离之和,只要求每条边乘上每条边出现的次…
#include<bits/stdc++.h> using namespace std; struct node{ int u, v, w, nex; bool gone; node(){} node(int a,int b,int c){ u = a;v = b;w = c;gone = false; } bool operator <(const node&a)const{ return w < a.w; } }; ; ; node Gra[maxE]; int dp[…
题目链接:hdu 5723 Abandoned country 题目大意:N个点,M条边:先构成一棵最小生成树,然后这个最小生成树上求任意两点之间的路径长度和,并求期望 /************************************************************** Problem:hdu 5723 User: youmi Language: C++ Result: Accepted Time:2932MS Memory:22396K solution:首先注意到任…
Abandoned country 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5723 Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) ro…
Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) roads to be re-built, the length of each road is wi(wi≤1000000). Guarante…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5723 Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 7573    Accepted Submission(s): 1850 Problem Description An abandoned country…