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

建议使用的浏览器:

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

6664:Andy and Maze

题目描述
Andy is a famous explorer at Nanjing University second to none. One day he was trapped in a maze. The maze consisted of several rooms, and there was a precious gem in each room. There were also some bidirectional roads connecting some pairs of these rooms. It took some time to travel along the road in either direction.

Andy was in a room, but he didn't know which room he was in. Suddenly, he heard a low voice, saying that, "if you want to get out of the maze, you must collect $k$ gems." Andy wanted to know, what was the maximum possible time to get out of the maze, or it was impossible at all? Note that he couldn't visit the same room more than once.
输入解释
The first line of input consists of a single integer $T$ $(1 \leq T \leq 35)$, denoting the number of test cases. Each test case starts with a line of three integers $n, m, k$ $(2 \leq n \leq 10^4, 1 \leq m \leq 10^4, 2 \leq k \leq 6)$, denoting the number of rooms and the number of roads in the maze, and the number of gems he needed to collect, respectively. Each of the next $m$ lines contains three intergers $u, v, t$ $(1 \leq u, v \leq n, u \neq v, 1 \leq t \leq 10^8)$, specifying a road connecting the $u$th and the $v$th rooms, which took $t$ minutes to travel in either direction. No two roads connected the same pair of rooms.
There are at most 5 test cases with $\max\{n, m\} > 100$.
输出解释
For each test case, print the maximum possible time in minute to get out of the maze in one line. If it was impossible to get out of the maze, print $\texttt{impossible}$ instead.
输入样例
2
4 4 3
1 2 6
2 3 1
2 4 4
1 4 5
5 3 4
1 2 2
2 3 3
4 5 5
输出样例
11
impossible
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6664

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

共提交 0

通过率 --%
时间上限 内存上限
15000/15000MS(Java/Others) 131072/131072K(Java/Others)