Walkie-talkie
Time limit1sMemory limit128 MB
Given a planar track network, find all cities Slawek can visit while Mirek positions himself elsewhere so they stay within distance d at all times.
- Level
Hard8 of 10
- Topics
- Graph, Geometry, BFS, Shortest path
- Solved
- No attempts yet
Problem
Mirek and Sławek were recently hired as locomotive drivers at the national railway. On their very first day they are given an interesting assignment: each of them must start from a predetermined city and drive his locomotive through as many cities as possible.
Mirek is an experienced driver and is afraid of nothing. For Sławek it is the first time, so he cannot do anything with a train on his own. Fortunately every locomotive is equipped with a walkie-talkie, so Mirek can give Sławek instructions as long as the two of them stay within the range of the device.
Cities are represented by points in the plane. Some pairs of cities are joined by railway tracks, that is, by segments connecting the given points. Mirek and Sławek begin their journey in cities that are at most kilometers apart.
A locomotive may travel along the tracks in either direction and at any speed (it may also stop at any place), but it may switch to another track only at a city. At every moment Mirek and Sławek must be at most kilometers apart.
Write a program that finds every city Sławek can visit under the rules described above. The program should:
- read from standard input the description of the railway network, the number , and the starting positions of Mirek and Sławek,
- find the cities Sławek can reach,
- write the result to standard output.
Input
The first line contains integers and (, ) and a real number (, has at most two digits after the decimal point). They denote, respectively, the number of cities, the number of track segments, and the range of the walkie-talkie in kilometers. Cities are numbered from to . Each of the next lines contains the coordinates of a city , (). The next lines describe the railway network; each of them contains two integers, the numbers of the two cities joined by a track segment. The last line contains the numbers of the cities where Mirek and Sławek start their journey, in that order. These two cities are at most kilometers apart.
Output
Print the numbers of the cities Sławek can reach. The numbers must be sorted in increasing order and printed one per line.