The Temple
Time limit1sMemory limit128 MB
Given circles (columns) and two points, find the shortest path between the points that cannot pass through any circle.
- Level
Hard8 of 10
- Topics
- Geometry, Graph, Shortest path, Math
- Solved
- No attempts yet
Problem
A team of archaeologists is about to start excavating an ancient temple, and the first task is to light up the site. The temple is a wide, flat floor on which many tall cylindrical columns stand. The team puts one power source and several lamps on the floor and wants to connect every lamp to the power source with the shortest possible wire. Find the length of each wire.
To keep the model simple, assume the following:
- no two columns touch each other;
- a wire has no thickness, must lie flat on the floor, and may touch a column but may never pass through it;
- the power source and the lamps are treated as points and never touch a column.
Viewed from above, the columns are circles and the power source and lamps are points. For each lamp, write a program that computes the length of the shortest wire connecting it to the power source.
Input
The first line contains the number of columns (). Each of the next lines describes one column with three integers , , (, ): the centre and the radius of the column. The next line contains the number of lamps (). Each of the next lines contains the coordinates , () of one lamp. The last line contains the coordinates , () of the power source.
Output
Print lines. On the -th line, print the length of the shortest wire connecting the -th lamp to the power source, rounded to exactly six digits after the decimal point (such as 9.278662).
Hint

The figure illustrates a layout of columns and wires.