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

建议使用的浏览器:

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

5521:Meeting

题目描述
Bessie and her friend Elsie decide to have a meeting. However, after Farmer John decorated his
fences they were separated into different blocks. John's farm are divided into $n$ blocks labelled from $1$ to $n$.
Bessie lives in the first block while Elsie lives in the $n$-th one. They have a map of the farm
which shows that it takes they $t_i$ minutes to travel from a block in $E_i$ to another block
in $E_i$ where $E_i~(1\le i\le m)$ is a set of blocks. They want to know how soon they can meet each other
and which block should be chosen to have the meeting.
输入解释
The first line contains an integer $T~(1\le T\le 6)$, the number of test cases. Then $T$ test cases
follow.

The first line of input contains $n$ and $m$. $2 \leq n \leq 10^5$. The following $m$ lines describe the sets $E_i~(1\le i\le m)$. Each line will contain two integers $t_i(1 \leq t_i \leq 10^9)$ and $S_i~(S_i>0)$ firstly. Then $S_i$ integer follows which are the labels of blocks in $E_i$. It is guaranteed that $\sum_{i=1}^m{S_i} \leq 10^6$.
输出解释
For each test case, if they cannot have the meeting, then output "Evil John" (without quotes) in one line.

Otherwise, output two lines. The first line contains an integer, the time it takes for they to meet.
The second line contains the numbers of blocks where they meet. If there are multiple
optional blocks, output all of them in ascending order.
输入样例
2
5 4
1 3 1 2 3
2 2 3 4
10 2 1 5
3 3 3 4 5
3 1
1 2 1 2
输出样例
Case #1: 3
3 4
Case #2: Evil John
提示
In the first case, it will take Bessie 1 minute travelling to the 3rd block, and it will take Elsie 3 minutes travelling to the 3rd block. It will take Bessie 3 minutes travelling to the 4th block, and it will take Elsie 3 minutes travelling to the 4th block. In the second case, it is impossible for them to meet.
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5521

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

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 262144/262144K(Java/Others)