Time limit
2s
Memory limit
128 MB
A newly opened zoo plans to build a lion enclosure in the shape of an orthogonal polygon. An orthogonal polygon is a simple polygon whose every side is parallel to either the x-axis or the y-axis. Exactly one side of the enclosure will be made of glass so that visitors can see inside, and every other side will be made of concrete.
During winter, the lion stays inside the enclosure, so visitors observe it through the glass wall. Given the orthogonal polygon for the enclosure and the side used as the glass wall, find the interior region that is visible from every point on that glass wall. A visitor who moves along the glass wall may see a larger union of regions, but this problem asks only for the region common to all viewing positions. Assume there are no obstacles inside the enclosure.
The first line contains the number of vertices n of the orthogonal polygon. (4 <= n <= 10,000)
Each of the next n lines contains the x-coordinate and y-coordinate of one vertex, listed in counterclockwise order. The glass wall is the side connecting the first and second input points.
All coordinates are integers, and the absolute value of each coordinate is at most 10,000. There is at least one space between adjacent integers.
Print the perimeter of the polygon that represents the interior region visible from every point on the glass wall. Round the answer to two digits after the decimal point, and always print trailing zeros. Values such as 25.00 and 8.70 must be printed in that form.