#P6719. Maximum Radius for Two Circles in a Convex Polygon

    ID: 19927 Type: Default 1000ms 256MiB

Maximum Radius for Two Circles in a Convex Polygon

Maximum Radius for Two Circles in a Convex Polygon

Given a convex polygon with N vertices provided in counter‐clockwise order on the Cartesian plane, you are to determine the maximum possible radius R such that two circles, both of radius R, can be placed inside the polygon without overlapping (they may touch). In other words, the centers of the two circles must lie within the erosion (or offset) of the polygon by distance R (i.e. the set of points that are at least distance R away from every polygon edge), and the distance between the two centers must be at least 2R.

The problem can be solved by performing a binary search on R. For a candidate R, one can compute the offset polygon (by shifting every edge inward by R) and then check whether there exist two points in the offset polygon that are separated by at least 2R (in a convex polygon, the maximum distance is its diameter). If such two points exist, the candidate is feasible; otherwise it is not. The answer is the maximum feasible R within a small precision error.

Note on computing the offset polygon: For a convex polygon given in counter‐clockwise order, each edge from point Pi to Pi+1 (indices modulo N) is shifted inward along its left normal. The intersection of consecutive shifted lines yields the vertices of the eroded polygon. If the offset polygon is empty (has less than 3 vertices), the candidate R is not feasible.

Input constraints: The first line contains an integer N (the number of vertices). The following N lines each contain two real numbers representing the coordinates of the polygon vertices in counter‐clockwise order.

Output: Output the maximum possible value of R satisfying the conditions. Answers within an absolute error of 1e-6 will be accepted.

inputFormat

The input begins with an integer N (number of vertices). Then follow N lines, each containing two floating‐point numbers x and y, which represent the coordinates of the vertices of the convex polygon in counter‐clockwise order.

outputFormat

Output a single floating‐point number representing the maximum radius R such that two circles of radius R can be placed inside the polygon without overlapping. Print the answer with at least 6 decimal places of precision.

sample

4
0 0
10 0
10 10
0 10
2.928932