ZOJ Problem Set - 2663
Closed polyline (with possible self-intersections) partitions a plane into a number of regions. One of the regions is unbounded --- it is an exterior of the polyline. All the bounded regions together with the polyline itself form an interior of the polyline (shaded on the picture below). The border of the interior (bold line on the picture) is a polyline as well. This polyline has the same interior as the original one.
Your task is to find the border of the interior of the given polyline.
To guarantee the uniqueness (up to the starting point) of the polyline representing the border we require that the following conditions are satisfied for it:
There are several test cases in the input. The first line of each case contains an integer number n (3 ≤ n ≤ 100) --- the number of vertices in the original polyline. Following n lines contain two integer numbers xi and yi on a line (0 ≤ xi , yi ≤ 100) --- coordinates of the vertices. All vertices are different and no vertex lies on an edge between two other vertices. Adjacent edges of the polyline are not collinear.
Write to the output file an integer number m --- the number of vertices of the border. Then write m lines with coordinates of the vertices. Coordinates must be precise up to 4 digits after the decimal point.
Source: Northeastern Europe 2004