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

建议使用的浏览器:

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

1370:Gossiping

题目描述
There was a public bus transport in one town. All buses had circular lines. Each line had at least two stops. Some lines had some stops in common. When two or more bus drivers met on some stop they announced each other all news they knew, so that after leaving the stop they all knew the same news. All drivers started driving their buses at the same time and at this time each driver knew some news that was not known to any other driver. Each bus ran all the time along a fixed bus line. Different buses running along the same bus line started possibly on different stops of the bus line at the beginning.
The operation of buses was highly synchronized. The time necessary to get from one stop to next stop was equal for all stops and all lines.

There were n lines ( 0 < n < 20), d drivers (and also d buses) ( 0 < d < 30) numbered by integers from 1 to d, and s bus stops ( 0 < s < 50) numbered by integers from 1 to s.

The drivers' gossiping club would like to know whether each driver, in some time, would learn all news from his colleagues. Write a program that will answer this question.
输入解释
The input consists of blocks of lines. Each block except the last describes one town. In the first line of the block there are integers n, d and s described above separated by one space. The next 2n lines contain descriptions of n bus lines (2 lines for each bus line) as follows: In the first line there are stop numbers on the corresponding bus line separated by one space. The stops are listed in the order the bus passes them. After passing the last stop listed on the line the bus goes again to the first stop listed on the line. The second line describes on which stops the individual buses operating on the bus line started at the beginning. The description consists of pairs si, di, where si is a stop number on the bus line and di is the number of driver driving the bus. All numbers si, di on the line are separated by one space. The last block consists of just one line containing 0 0 0, i.e. three zeros separated by one space.
输出解释
The output contains the lines corresponding to the blocks in the input. A line contains Yes if the corresponding block in the input file describes a situation where each driver will learn, in some time, all news from his colleagues. Otherwise it contains No. There is no line in the output corresponding to the last ``null'' block of the input.
输入样例
2 3 5
1 2 3
1 1 2 2
2 3 4 5
2 3
0 0 0
输出样例
Yes

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Central Europe 1997

源链接: POJ-1370

最后修改于 2020-10-29T06:02:09+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000