The Largest Circle
Time limit5sMemory limit128 MB
Given N segments, find the maximum radius of a circle centered on the x-axis within [0,L] that touches but never crosses any segment, using binary search plus geometric distance checks.
- Level
Hard8 of 10
- Topics
- Binary search, Geometry, Math
- Solved
- No attempts yet
Problem
There are line segments in the two-dimensional plane. Write a program that finds the radius of the largest "empty" circle satisfying all of the following:
- The circle's center is .
- .
- (that is, the center lies on the -axis).
An "empty" circle is one that does not cross any of the given segments. Touching a segment (tangency) is allowed.
Input
The first line contains the number of test cases . Each test case has the following form:
- One line with two integers and (, ).
- The next lines each contain four integers describing the two endpoints of a segment; that is, the segment's endpoints are and .
All coordinates are integers between and , inclusive.
Output
For each test case, output on one line the radius of the largest circle, rounded to three digits after the decimal point.