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

建议使用的浏览器:

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

2394:Checking an Alibi

题目描述
A crime has been comitted: a load of grain has been taken from the barn by one of FJ's cows. FJ is trying to determine which of his C (1 <= C <= 100) cows is the culprit. Fortunately, a passing satellite took an image of his farm M (1 <= M <= 70000) seconds before the crime took place, giving the location of all of the cows. He wants to know which cows had time to get to the barn to steal the grain.

Farmer John's farm comprises F (1 <= F <= 500) fields numbered 1..F and connected by P (1 <= P <= 1,000) bidirectional paths whose traversal time is in the range 1..70000 seconds (cows walk very slowly). Field 1 contains the barn. It takes no time to travel within a field (switch paths).

Given the layout of Farmer John's farm and the location of each cow when the satellite flew over, determine set of cows who could be guilty.

NOTE: Do not declare a variable named exactly 'time'. This will reference the system call and never give you the results you really want.
输入解释
* Line 1: Four space-separated integers: F, P, C, and M

* Lines 2..P+1: Three space-separated integers describing a path: F1,F2, and T. The path connects F1 and F2 and requires T seconds to traverse.

* Lines P+2..P+C+1: One integer per line, the location of a cow. The first line gives the field number of cow 1, the second of cow 2, etc.
输出解释
* Line 1: A single integer N, the number of cows that could be guilty of the crime.

* Lines 2..N+1: A single cow number on each line that is one of the cows that could be guilty of the crime. The list must be in ascending order.
输入样例
7 6 5 8
1 4 2
1 2 1
2 3 6
3 5 5
5 4 6
1 7 9
1
4
5
3
7
输出样例
4
1
2
3
4
提示
INPUT DETAILS:

Fields/distances like this:
          6

4------5
| |
2| |
| |
7-----1 |5
9 | |
1| |
| |
2------3

OUTPUT DETAILS:

Any cow except cow 5 could have done it. Cow 5 would take 9 seconds to get to the barn.

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

源链接: POJ-2394

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

共提交 0

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