QOJ.ac

QOJ

时间限制: 1 s 内存限制: 128 MB 总分: 100

#13193. Jigsaw Puzzle

统计

5-year-old P is very interested in paper cutting. He likes to cut a rectangular piece of paper into several convex polygons. However, after each cutting session, he always suspects that he has lost some pieces. The clever boy came up with a method to check if any pieces were lost: he tries to assemble these convex polygons back together. If they can form a rectangle, he assumes that no pieces were lost. Since the number of pieces is not large, this task is not difficult. However, over time, he lost interest in this work, so he has come to you, hoping you can tell him whether these convex polygon pieces can form a rectangle.

Input

The first line contains a single positive integer $n$ ($1 \le n \le 8$), representing the number of convex polygons.

The next $n$ lines each describe a convex polygon in the following format: The first number $m_i$ ($3 \le m_i \le 8$) on the $(i+1)$-th line represents the number of vertices of the convex polygon, followed by $m_i$ pairs of real numbers. Each pair of real numbers gives the coordinates of a vertex. These $m_i$ vertices are given in counter-clockwise order starting from an arbitrary vertex. All real numbers are in the range $(-1000, 1000)$ and have no more than 8 decimal places.

Output

If they cannot form a rectangle, output a single line containing "No".

If they can form a rectangle, output "Yes" on the first line. The following $n$ lines describe the assembly. If they can form an $X \times Y$ rectangle, the coordinates of the four vertices of the rectangle are $(0,0)$, $(0,Y)$, $(X,Y)$, and $(X,0)$. These $n$ lines should output the coordinates of the vertices of each convex polygon (after being assembled into the rectangle). Follow the input order, i.e., the first convex polygon output corresponds to the first convex polygon in the input. For each convex polygon, the output should also follow the input order, i.e., the first vertex of a polygon corresponds to the first vertex in the input. Thus, there are $n$ lines in total, and the $i$-th line contains $m_i$ pairs of numbers.

Examples

Input 1

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

Output 1

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

Note

As shown in the figure below, the top-left, top-right, and bottom-left parts describe the input convex polygons, and the bottom-right part describes the output rectangle.

Since the two sides of the rectangular paper have different colors, the pieces can only be rotated and translated, not flipped. Therefore, the output $m_i$ vertices must also be in counter-clockwise order.

Constraints

Two real numbers are considered equal if the absolute value of their difference is less than $10^{-7}$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.