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

建议使用的浏览器:

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

2591:Distance

题目描述
A city contains a number of streets connecting several junctions. All the streets are straight line segments connecting two junctions. The walking distance between two points (each either a junction or some intermediate point of a street) in the city is the shortest path from the first point to the second. You are allowed to walk only along the streets. Streets never intersect outside the junctions. Now, your goal is to find the maximal walking distance among any two points in the city.
输入解释
The input file contains several test cases. Each test case begins with two integers n and m ( 1<=n<=50, 0<=m<=n*(n-1)/2 ), which are the number of junctions and the number of streets. The following m lines each contain 3 integers Xi, Yi and Si ( 0<=Xi,Yi<n, 0<Si<=1000) indicating there is a street connecting junction Xi to Yi and the length is Si.
输出解释
For each test case, output the maximal walking distance among any two points in the city. Accurate up to 1 decimal places. If there is a point which is separate from some other one, just output -1.
输入样例
1 0
2 0
2 1
1 0 100
4 3
0 1 1
0 2 2
0 3 3
4 4
0 1 2
1 2 3
2 3 4
3 0 8
输出样例
0.0
-1
100.0
5.0
8.5
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-2591

最后修改于 2020-10-25T22:54:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)