当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5723:Abandoned country

题目描述
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.
输入解释
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 the minimum cost and minimum Expectations with two decimal places. They separated by a space.
输入样例
1
4 6
1 2 1
2 3 2
3 4 3
4 1 4
1 3 5
2 4 6
输出样例
6 3.33
来自杭电HDUOJ的附加信息
Author HIT
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5723

最后修改于 2020-10-25T23:25:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 65536/65536K(Java/Others)