POP-Partitioning an Orthogonal Polygon

A partition of a polygon P is a decomposition of P in which the component subpolygons do not overlap except at their boundaries. The elements that are obtained by means of the partition of P are called pieces. A polygon is called orthogonal if its edges meet at right angles. If each of the pieces of a partition are rectangular, then the partition is a rectilinear partition. A rectilinear partition of an orthogonal polygon can be obtained by extending each edge incident to a reflex vertex (the interior angle between its two incident vertices is at least π) of P through the interior of P until it hits the boundary of P (see Figure (a)). Write a program that, given a sequence of vertices, determine the rectilinear partition of a simple orthogonal polygon without holes. Input The input file contains several test cases, each of them as described below. The first line contains an integer N, 6 ≤ N ≤ 50, which is the number of vertices in the orthogonal polygon. The following N lines contain two non-negative integers X and Y , 0 ≤ X, Y ≤ 20, separated by a space. Each of the pairs (X, Y ) specify the x-coordinate and the y-coordinate of a vertex. (See the Sample Input, which corresponds to the situation in the Figure (a) above.) Output For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

2/2 The output is the rectilinear partition of the polygon, where each set of four lines represent a rectilinear piece. The pieces must be listed from left to right and from top to bottom. The vertexes of each piece must be listed as indicated in Figure (b). Sample Input 8 12 42 41 51 55 35 34 14 Sample Output 14 12 32 34 35 34 44 45 34 32 42 44 45 44 54 55 44 42 52 54 42 41 51 52