Clock
InterviewTime limit1sMemory limit128 MB
Find the largest empty circle fully inside a rectangular wall that avoids up to 50 non-overlapping discs, using a generalized Voronoi diagram of points, segments, and circles.
- Level
Hard8 of 10
- Topics
- Geometry, Divide and conquer, Sorting, Math
- Solved
- No attempts yet
Problem
Heewon collects round wall clocks and has hung all of them on a single wall in the living room. He now wants to buy one more clock and hang it in the empty space, without moving any of the clocks that are already on the wall. He wants the largest possible round clock that can still be hung.
The wall is a rectangle of width and height . Each hanging clock is a circle with center and radius . The existing clocks stay within the wall and never overlap one another (though they may touch).
The new clock is also a circle. It must lie entirely within the wall and must not overlap any existing clock (touching is allowed). Find the largest radius of such a clock. This maximum radius is uniquely determined.
Input
The first line contains the number of test cases .
Each test case is given as follows.
- The first line contains the width and height of the wall, and . ()
- The second line contains the number of clocks hanging on the wall, . ()
- Each of the next lines contains one clock's data , , . (, , , , )
Every pair of distinct clocks , () satisfies .
Output
For each test case, print on its own line the radius of the largest clock that can be hung, rounded to six digits after the decimal point.