#P15490. [IOI 2004] Polygon
[IOI 2004] Polygon
Description
A polygon consists of all points on or enclosed by its border. A convex polygon has the property that for any two points and of the polygon, the line segment connecting and is inside the polygon. All polygons in this task are convex polygons with at least two vertices, and all vertices in a polygon are different and have integer coordinates. No three vertices of the polygon are collinear. The word “polygon” below always refers to such polygons.
Given two polygons and , the Minkowski sum of and consists of all the points of the form where is a point in and is a point in . It turns out that the Minkowski sum of polygons is also a polygon. The figure below shows an example: two triangles and their Minkowski sum.
We study a reverse operation to the Minkowski sum. For a given polygon , we are looking for two polygons and such that:
- is the Minkowski sum of and ,
- has from to different vertices, i.e. it is a segment ( vertices), a triangle ( vertices) or a quadrilateral ( vertices),
- should have as many vertices, as possible, i.e.:
- should be a quadrilateral, if possible,
- if cannot be a quadrilateral, it should be a triangle, if possible,
- otherwise it should be a segment.
Clearly, neither nor can be equal to because then the other summand would have to be a point, which is not a valid polygon.
You are given a set of input files, each containing a description of a polygon . For each input file you should find the polygons and , as required above, and create an output file containing descriptions of and . For the given input files such polygons and can always be found. If there are many correct results, you should find and output one of them. You should not submit any programs, just the output files.
Input Format
You are given problem instances in the text files named polygon1.in to polygon10.in, where the number after polygon is the input number. Each input file is organized as follows. The first line contains one integer : the number of vertices of the polygon . The following lines describe the vertices in a counter-clockwise order, one vertex per line. Line (for ) contains two integers and , separated by a space: coordinates of the th vertex of the polygon. All input coordinates are non-negative integers.
Output Format
You are to submit output files corresponding to the given input files which describe the required polygons and .
The output format is similar to the input format. The second line is to contain one integer : the number of vertices in . The following lines describe the vertices of in the counter-clockwise order, one vertex per line. Line (for ) contains two integers and , separated by a space: coordinates of the th vertex of the polygon . Line should contain one integer : the number of vertices in ,. The following lines describe the vertices of in the counter-clockwise order, one vertex per line. Line (for ) contains two integers and , separated by a space: coordinates of the th vertex of the polygon .
5
0 1
0 0
2 0
2 1
1 2
3
0 0
2 0
1 1
2
0 1
0 0
或
3
0 0
1 0
1 1
3
0 1
0 0
1 0
京公网安备 11011102002149号