#7816. [IOI 2004] Polygon

[IOI 2004] Polygon

[IOI 2004] Polygon

题目描述

A polygon consists of all points on or enclosed by its border. A convex polygon has the property that for any two points $X$ and $Y$ of the polygon, the line segment connecting $X$ and $Y$ 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 AA and BB, the Minkowski sum of AA and BB consists of all the points of the form (x1+x2,y1+y2)(x1+x2, y1+y2) where (x1,y1)(x1, y1) is a point in AA and (x2,y2)(x2, y2) is a point in BB. 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 PP, we are looking for two polygons AA and BB such that:

  • PP is the Minkowski sum of AA and BB,
  • AA has from 22 to 44 different vertices, i.e. it is a segment (22 vertices), a triangle (33 vertices) or a quadrilateral (44 vertices),
  • AA should have as many vertices, as possible, i.e.:
    • AA should be a quadrilateral, if possible,
    • if AA cannot be a quadrilateral, it should be a triangle, if possible,
    • otherwise it should be a segment.

Clearly, neither AA nor BB can be equal to PP 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 PP. For each input file you should find the polygons AA and BB, as required above, and create an output file containing descriptions of AA and BB. For the given input files such polygons AA and BB 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.

输入格式

You are given $10$ 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 $N$: the number of vertices of the polygon $P$. The following $N$ lines describe the vertices in a counter-clockwise order, one vertex per line. Line $I+1$ (for $I = 1, 2, \ldots, N$) contains two integers $X_I$ and $Y_I$, separated by a space: coordinates of the $I$th vertex of the polygon. All input coordinates are non-negative integers.

输出格式

You are to submit $10$ output files corresponding to the given input files which describe the required polygons $A$ and $B$.

The output format is similar to the input format. The second line is to contain one integer NAN_A: the number of vertices in A(2≤NA≤4)A (2\le N_A\le4). The following NAN_A lines describe the vertices of AA in the counter-clockwise order, one vertex per line. Line I+2I+2 (for I=1,2,…,NAI = 1, 2, \ldots, N_A) contains two integers XX and YY, separated by a space: coordinates of the IIth vertex of the polygon AA. Line NA+3NA+3 should contain one integer NBN_B: the number of vertices in BB,(2≤NB)(2\le NB). The following NBN_B lines describe the vertices of BB in the counter-clockwise order, one vertex per line. Line NA+J+3N_A+J+3 (for J=1,2,…,NBJ = 1, 2, \ldots, N_B) contains two integers XX and YY, separated by a space: coordinates of the JJth vertex of the polygon BB.

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

提示

(暂无提示) 标签: P15490|2004|IOI|提交答案|Special Judge

来源

P15490|[IOI 2004] Polygon