#P5790. [CTSC2006] 拼图「暂缺SPJ」
[CTSC2006] 拼图「暂缺SPJ」
Problem Description
Little , who is years old, is very interested in paper cutting. He always likes to cut a rectangular piece of paper into one convex polygon after another. However, after each cutting, he always suspects that he has lost some pieces. Being smart, he came up with a way to check whether any pieces were lost: he puts these convex polygons together, and if they can form a rectangle, he believes that no piece was lost.
Since the number of pieces is not large, this work is not difficult. But over time, he lost interest in doing it, so he came to you and hopes that you can tell him whether these convex polygon pieces can be assembled into a rectangle.
Input Format
The first line contains one positive integer , indicating the number of convex polygons.
The following lines each describe one convex polygon in the format below:
On line , the first number is the number of vertices of the convex polygon. Then there are pairs of real numbers, where each pair gives the coordinates of a vertex. These vertices are given in counterclockwise order starting from any vertex. All real numbers are in the range , with at most digits after the decimal point.
Output Format
If the polygons cannot be assembled into a rectangle, output one line containing No.
If they can be assembled into a rectangle, the first line should be Yes.
The next lines describe the assembly.
If they can form an rectangle, then the coordinates of the rectangle’s four vertices are . In these lines, output the coordinates of the vertices of each convex polygon (after assembling into the rectangle). Output in the input order, i.e., the first polygon in the output corresponds to the first polygon in the input. For each polygon, the output order should also match the input order, i.e., the first output vertex corresponds to the first input vertex of that polygon. Therefore, there are output lines in total, and line contains pairs of numbers.
3
4 0 0 4 -1 5 4 0 4
4 0 0 5 -1 8 3 0 3
4 0 0 0 -8 3 -4 4 0
Yes
0 4 4 3 5 8 0 8
5 8 4 3 8 0 8 8
0 0 8 0 4 3 0 4
Hint
Sample Explanation
In the figure below, the top-left, top-right, and bottom-left parts show the input convex polygons, and the bottom-right part shows the output rectangle.

Note
Because the two sides of the rectangular paper have different colors, each piece can only be rotated and translated, but cannot be flipped. Therefore, the output vertices should also be in counterclockwise order.
Constraints
For of the testdata, , .
Scoring
Two real numbers are considered equal if the absolute value of their difference is less than .
Translated by ChatGPT 5