A convex polygon with n vertices is given via the coordinates of the vertices, which are given in clockwise order. A point S from the plain of the polygon is the center of symmetry, if the symmetric of any polygon point as compared to S belongs to the polygon. One of the property of convex polygons with a center of symmetry is that they can be decomposed into parallelograms.
Task
Verify whether the given polygon has a center of symmetry. If positive, divide the polygon into parallelograms.
Input Data
Input file poligon.in contains on line one a non-zero positive integer k, which represents the number of tests, followed by k data groups, one group for each test. A data group contains on a line the number n, and on the following n lines the coordinates of the polygon's vertices in the following format:
n
x1 y1
x2 y2
…
xn yn
Output Data
Output file poligon.out will contain the answer to the k tests of the input file. For each test the positive integer h, representing the number of parallelograms from the decomposition will be written on a line, followed by h lines with the coordinates of the vertices of the parallelograms resulting from the decomposition, in format:
h
px11 py11 px21 py21 px31 py31 px41 py41
px12 py12 px22 py22 px32 py32 px42 py42
…
px1h py1h px2h py2h px3h py3h px4h py4h
if there is a center of symmetry, otherwise only digit 0 will be written.
A parallelogram is described via the coordinates of its vertices in clockwise order (abscise ordinate).
Constraints and Statements
poligon.in | poligon.out |
2 |
0 6 20 0 10 10 20 10 30 0 10 10 10 20 20 20 20 10 10 20 20 30 30 30 20 20 20 10 20 20 30 10 30 0 20 20 30 30 40 20 30 10 40 20 40 10 30 0 30 10 |
Time limit: 0.1 seconds/test
prof. Doru Popescu Anastasiu
"Radu Greceanu" National College Slatina
Contact:dopopan@yahoo.com