Radio Range Train Tour
Time limit1sMemory limit128 MB
Given a town graph, find all towns Slavko can reach while continuously staying within distance D of Mirko as both move along tracks simultaneously.
- Level
Hard8 of 10
- Topics
- Graph, BFS, Shortest path
- Solved
- No attempts yet
Problem
Mirko and Slavko have become locomotive drivers. On their first day, each of them must start from a given town and try to visit as many towns as possible.
Mirko is experienced and can drive on his own. Slavko is driving for the first time, so he can drive normally only while he is within range of Mirko's radio and can receive instructions.
There are N towns on a coordinate plane, and some pairs of towns are connected by railroad tracks. Mirko and Slavko start in different towns whose distance is at most D kilometers.
Both locomotives may use any track, in either direction, at any speed. They may switch tracks only at towns. At every moment, the distance between the two locomotives must be at most D kilometers.
Determine every town that Slavko can visit under these rules.
Input
The first line contains integers N and P, and a real number D (2 <= N <= 100, 1 <= P <= 3000, 1 <= D <= 10000). N is the number of towns, P is the number of railroad tracks, and D is the radio range in kilometers. The value D is given with at most two digits after the decimal point. The towns are numbered from 1 to N.
Each of the next N lines contains two integers X and Y (-5000 <= X, Y <= 5000), the coordinates of one town.
Each of the next P lines contains two integers G1 and G2, meaning that a railroad track connects towns G1 and G2.
The last line contains two integers U and V, the starting towns of Mirko and Slavko. The distance between towns U and V is at most D.
Output
Print the numbers of all towns that Slavko can reach, in increasing order, one per line.