第一问就是裸MST。。
第二问求2点之间距离期望。。就是把距离和全求一遍然后除以n(n-1)嘛。。
所以就是求距离和了。。经典树DP。。
对每个点X分别枚举累加节点深度和(深度指到子树根的距离),对每个儿子t,只要用距离和乘t的节点数,再加上t距离和乘以当前x的节点数,就能算出经过x的路径和了。。
Abandoned country
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 6957 Accepted Submission(s): 1703
Problem Description
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). Guaranteed that any two wi
Input
T(T≤10) which indicates the number of test cases.
For each test case, the first line contains two integers
n,m indicate the number of villages and the number of roads to be re-built. Next
m lines, each line have three number
i,j,wi, the length of a road connecting the village
i and the village
j is
wi.
Output
output the minimum cost and minimum Expectations with two decimal places. They separated by a space.
Sample Input
1 4 6 1 2 1 2 3 2 3 4 3 4 1 4 1 3 5 2 4 6
Sample Output
6 3.33
Author
HIT
Source
2016 Multi-University Training Contest 1
Recommend
wange2014 | We have carefully selected several similar problems for you: 6275 6274 6273 6272 6271
Statistic |
Submit |
Discuss |
Note