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

建议使用的浏览器:

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

5915:The Fastest Runner Ms. Zhang

题目描述
Ms. Zhang is a journalist from Hong Kong, and she runs very very fast, so every one calls her “The fastest runner”. There are n cities (numbered from 1 to n) and n roads in the country, the roads are undirected. It costs 1 unit of time to go through each road. There exists at least one path between any pair of cities. Now Ms. Zhang can start her interview in city S, visit all of the n cities and finish her interview in city T. Since Ms. Zhang’s interview is simple and naive, the interview does not cost any time. Can you help Ms. Zhang to find the optimal S and T that minimise the total traveling time of Ms. Zhang? If there are multiple optimal solutions, output the solution with the smallest S. If there are still multiple solutions, output the solution with the smallest T.
输入解释
The first line contains only one integer T ($T\leq 40$), which indicates the number of test cases.

Each test case contains n + 1 lines.

The first line contains one integer $1\leq n\leq 10^5$.

In the next n lines, each line contains two integers x and y indicating there is a road between city x and city y.

It is guarenteed that there does not exist a road connecting one city to itself or two roads connecting the same pair of cities.
输出解释
For each test case, output one line “Case #x: t S T ”, where x is the case number(starting from 1),t is the minimal total traveling time, S and T are the index of starting and ending city.
输入样例
1
10
7 1
5 3
4 5
8 9
6 4
8 6
2 7
10 3
4 1
9 7
输出样例
Case #1: 10 1 10
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5915

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

共提交 0

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