#P6770. [USACO05MAR] Checking an Alibi 不在场的证明
[USACO05MAR] Checking an Alibi 不在场的证明
Description
Grain has been found stolen from the barn! FJ is trying to find the criminal who stole the grain among cows. Luckily, a satellite passing by took a picture of the farm seconds before the grain was stolen. This allows John to determine who had enough time to steal the grain based on the cows' positions.
John's farm has fields, numbered from to , and bidirectional roads connecting them. The travel time along these roads ranges from to seconds. The stolen barn is located on field . Given the farm map and each cow's position in the satellite photo, determine which cows could be guilty.
Note: The testdata may contain multiple edges (edges with the same start and end).
A “cow that could be guilty” means a cow that can reach field from its position in the photo within seconds.
Input Format
Line : Four space-separated integers: and .
Lines to : Three space-separated integers describing a road. The road connects and and takes seconds to travel.
Lines to : Each line contains one integer, the position of a cow.
Output Format
Line : Output the number of suspects. Then, output one suspect cow index per line, sorted in increasing 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
Hint
Data Specification
For of the testdata: , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号