문제
Note: The time limit for this problem is 3s, 1.5x the default. The memory limit for this problem is 512MB, twice the default.
Farmer John would like to promote his line of Bessla electric tractors by showcasing Bessla's network of charging stations. He has identified () points of interest labeled , of which the first () are charging stations and the remainder are travel destinations. These points of interest are interconnected by () bidirectional roads, the -th of which connects distinct points and () and has length miles ().
A Bessla can travel up to miles () on a single charge, allowing it to reach any destination within miles of a charging station. A destination is deemed well-connected if it is reachable from at least () distinct charging stations. Your task is to assist Farmer John in identifying the set of well-connected travel destinations.
입력
The first line contains five space-separated integers , , , , and . Each of the following lines contains three space-separated integers , , and such that .
The charging stations are labeled . The remaining points of interest are all travel destinations.
출력
First, output the number of well-connected travel destinations on a single line. Then, list all well-connected travel destinations in ascending order, each on a separate line.
예제 입력 1
3 3 1 4 1
1 2 3
1 3 5
2 3 2
예제 출력 1
1
2
예제 입력 2
4 3 2 101 2
1 2 1
2 3 100
1 4 10
예제 출력 2
2
3
4
예제 입력 3
4 3 2 100 2
1 2 1
2 3 100
1 4 10
예제 출력 3
1
4
점수
Inputs 4 and 5: and and .Inputs 6 and 7: .Inputs 8-15: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인