Two Circles in a Convex Polygon
Time limit4sMemory limit128 MB
Find the largest radius R so that two non-overlapping circles of radius R fit inside a given convex polygon with N vertices.
- Level
Hard9 of 10
- Topics
- Geometry, Binary search, Divide and conquer, Math
- Solved
- No attempts yet
Problem
You are given a convex polygon with vertices. Find the largest radius such that two circles of radius can both be placed entirely inside the polygon without overlapping (touching is allowed).
Input
The first line contains the number of vertices . Each of the next lines contains two integers and , separated by a space, giving the coordinates of the -th vertex.
Output
Print the maximum radius on a single line, rounded to exactly three decimal places.
Constraints
- The vertices are given in counter-clockwise (trigonometric) order.
Hint
For a square, the radius is maximised when the centres of the two circles lie on one of its diagonals. In that case the radius can be computed exactly as
