Track Smoothing
Time limit2sMemory limit128 MB
Given a convex polygon and minimum corner radius r, find the scale factor s so the inner-scaled offset track has the same perimeter as the original.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Math, Greedy
- Solved
- No attempts yet
Problem
Bob has to plan a racing track of a specific length. He first thought it would be a great idea to simply form a convex polygon whose perimeter is exactly the required length. Then he was told that racing cars cannot handle corners as sharp as the ones in his plan.
He must guarantee a minimum radius for every curve on the track. Because Bob loves the shape of his track, he does not want to change it too much. His plan is to scale the track down around the balance point (the centroid) of the polygon that describes it. He then draws the new track as a line kept at a constant distance from the scaled-down track, choosing the smallest distance that still satisfies the minimum-radius requirement. Write a program that computes the scale factor for a given track and minimum radius so that the resulting track has the same length as his original plan.
Bob made some drawings of the first test case:
Input
The first line contains the number of test cases (). Each test case begins with a line containing two integers: the minimum required radius and the number of vertices of the original track polygon (; ). The next lines each contain two integers and (), the coordinates of one polygon vertex; is the lower-left corner. The vertices are given in counterclockwise order, and the polygon is guaranteed to enclose a non-empty area.
Output
For each test case, print a single line. If a valid track can be constructed as described above, print the scale factor rounded to six digits after the decimal point (for example, 0.730494); otherwise print Not possible.