Abandoned country

TimeLimit:4000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
An abandoned country has $n (n \leq 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 \leq 1000000)$ roads to be re-built, the length of each road is $w_{i} (w_{i} \leq 1000000)$. Guaranteed that any two $w_{i}$ are different. The roads made all the villages connected directly or indirectly before destroyed. Every road will cost the same value of its length to rebuild. The king wants to use the minimum cost to make all the villages connected with each other directly or indirectly. After the roads are re-built, the king asks a men as messenger. The king will select any two different points as starting point or the destination with the same probability. Now the king asks you to tell him the minimum cost and the minimum expectations length the messenger will walk.
Input
The first line contains an integer $T (T \leq 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, w_{i}$, the length of a road connecting the village $i$ and the village $j$ is $w_{i}$.
Output
output the minimum cost and minimum Expectations with two decimal places. They separated by a space.
SampleInput
1
4 6
1 2 1
2 3 2
3 4 3
4 1 4
1 3 5
2 4 6
SampleOutput
6 3.33
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数5
总提交量5
AC率60.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: