shunfurh 于 2017.11.25 21:49 提问
- Find A Way
We'll consider an interesting geometric problem here. Given a number of circles with varying radius on the plane, and define the P-value of a point (x, y) on the plane as the number of circles covering this point. Here, by "covering", we mean that the point is either strictly within the circle, or on the boundary of the circle.
Given the starting position (Sx, Sy), and the destination position (Tx, Ty), please find a path between the two points, such that every point of the path is on the boundary of one or more circles, and the absolute difference between the maximum P-value and the minimum P-value among all points on the path is minimized.
Can you find the minimum absolute value with the help of your computer?
There are multiple test cases in the input file. Each test case starts with one integer N (1 <= N <= 150), the number of circles, followed by four real numbers, Sx, Sy, Tx, Ty, representing the x-coordinate and y-coordinate of the starting position and the destination. Each of the following N lines consists of three real numbers X, Y and R (R >= 1), indicating that there is a circle at position (X, Y) with radius R.
There is a blank line after each test case. Input ends with End-of-File.
Note: It is guaranteed that the input data is always legal, i.e. both the starting position and the destination are on the boundary of one or more circles, no two circles will be at the same position, every real number in the input file has at most three digits after the decimal point, and the absolute value of any real number does not exceed 10000.
For each test case, output one integer on one separate line as requested. If there is no way to reach the destination, output -1 instead.
-1.000 0.000 1.000 0.000
0.000 0.000 1.000
1.000 0.000 1.000
-1.000 0.000 5.000 0.000
-1.000 -1.000 1.000
4.000 0.000 1.000
Case 1: 1
Case 2: -1
- caozhy 2018.03.29 23:38