#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 CC cows. Luckily, a satellite passing by took a picture of the farm MM 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 FF fields, numbered from 11 to FF, and PP bidirectional roads connecting them. The travel time along these roads ranges from 11 to 7×1047\times 10^4 seconds. The stolen barn is located on field 11. 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 11 from its position in the photo within MM seconds.

Input Format

Line 11: Four space-separated integers: F,P,C,F, P, C, and MM.

Lines 22 to P+1P+1: Three space-separated integers describing a road. The road connects F1F_1 and F2F_2 and takes TT seconds to travel.

Lines P+2P+2 to P+C+1P+C+1: Each line contains one integer, the position of a cow.

Output Format

Line 11: 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 100%100\% of the testdata: 1M7×1041 \le M \le 7\times 10^4, 1C1001 \le C \le 100, 1P10001 \le P \le 1000, 1F5001 \le F \le 500.

Translated by ChatGPT 5