#P6848. [CEOI 2019] Scissors and Tape
[CEOI 2019] Scissors and Tape
Description
You are given a simple polygon , and you want to transform it into a simple polygon with the same area.
You can use two tools: scissors and tape. Scissors can cut any polygon into smaller polygons. Tape can glue smaller polygons into a larger polygon. You may use each tool any number of times, in any order.
All polygon vertices in the input have integer coordinates, but your solution is allowed to create polygons whose vertex coordinates are not integers.
The formal definition of the task is as follows:
A shape is a sequence of at least three points in the plane such that:
- The closed polyline does not self-intersect.
- This polyline goes counterclockwise around the boundary of the polygon.
The polygon with boundary given by shape is denoted by .
Two shapes are equivalent if and only if one can be translated or rotated to become identical to the other.
Reflection is not allowed, and the order of points matters: is not necessarily equivalent to .

In the figure above, shapes and are equivalent, but shape is not equivalent to them, because the order of the given points is different. In any case, the fourth shape is not identical to any of the first three, because reflection is not allowed.
Each shape is represented by numbers. The first number is , the number of points of the shape. Then follow numbers . Each pair of numbers gives the coordinates of one point in the shape; for example, is the coordinate of .
Shapes are called a partition of shape if and only if:
- The union of all equals .
- For all , and do not intersect.
Shapes have IDs. The ID of is . The shapes you create in your solution will have IDs .
Scissors cut an existing shape and produce a partition of .

In the figure above, shape is partitioned into three triangles . One way to describe the red triangle is 3 3 1 6 1 5.1 4.
Tape can glue existing shapes and turn them into a shape . To perform this operation, you must give and the final shape , and satisfy the following requirements:
- is equivalent to .
- form a partition of .
Informally, you choose the shape , and then show how to move each existing to its correct position to form . Note that shape must be assigned a new ID, but the do not need IDs.
Input Format
The first line is the shape .
The second line is the shape .
Output Format
Each time you use scissors, output in the following format:
scissors
id(A) k
B_1
B_2
...
B_k
Each time you use tape, output in the following format:
tape
k id(A_1) ... id(A_k)
C_1
C_2
...
C_k
B
Your output must satisfy the following constraints:
- All point coordinates in the output must be within .
- Each shape in the output may have at most points.
- In each operation, .
- The number of operations is at most .
- The total number of points across all shapes in the output does not exceed .
- In the end, there must be exactly one shape left, and it must be equivalent to .
6 0 0 6 0 6 4 5 4 5 9 0 9
4 0 0 7 0 7 7 0 7
scissors
0 5
3 0 0 3 0 3 4
3 3 4 0 4 0 0
3 3 0 6 0 6 4
3 6 4 3 4 3 0
4 0 4 5 4 5 9 0 9
tape
5 1 2 5 3 4
3 0 3 0 0 4 0
3 4 0 7 0 7 4
4 0 3 4 0 7 4 3 7
3 7 4 7 7 3 7
3 3 7 0 7 0 3
4 0 0 7 0 7 7 0 7
4 0 0 3 0 3 3 0 3
4 7 -1 10 -1 11 2 8 2
scissors
0 2
3 0 0 1 3 0 3
4 1 3 0 0 3 0 3 3
tape
2 1 2
3 110 -1 111 2 110 2
4 108 2 107 -1 110 -1 110 2
4 107 -1 110 -1 111 2 108 2
4 0 0 9 0 9 1 0 1
4 0 0 3 0 3 3 0 3
scissors
0 2
4 1.47000000000 0 9 0 9 1 1.470000000 1
4 0 0 1.470000000 0 1.470000000 1 0 1
scissors
1 2
4 1.470000000 0 6 0 6 1 1.470000000 1
4 9 0 9 1 6 1 6 0
tape
2 4 3
4 3 2 3 1 6 1 6 2
4 6 1 1.470000000 1 1.470000000 0 6 0
6 1.470000000 0 6 0 6 2 3 2 3 1 1.47 1
scissors
5 4
4 1.470000000 0 3 0 3 1 1.470000000 1
4 3 0 4 0 4 2 3 2
4 4 2 4 0 5 0 5 2
4 5 0 6 0 6 2 5 2
tape
5 2 6 7 8 9
4 0 0 1.470000000 0 1.470000000 1 0 1
4 1.470000000 0 3 0 3 1 1.470000000 1
4 0 2 0 1 2 1 2 2
4 0 2 2 2 2 3 0 3
4 3 3 2 3 2 1 3 1
4 0 0 3 0 3 3 0 3
Hint
Sample Explanation
Sample 1 Explanation

The top-left figure is the original shape after the scissors operation, and the right side shows the corresponding after using tape.
Sample 2 Explanation
Note that the target polygon and the polygon you finally obtain only need to be equivalent; they do not need to be exactly the same.
Sample 3 Explanation
The following figure shows the three stages of the output for this sample:

Constraints
For of the testdata, it is guaranteed that the number of points of and is and . All input point coordinates are within . No three points are collinear. The areas of and are equal.
If a shape has vertices where are positive integers, then it is called a good rectangle.
If a shape is a good rectangle and , then it is called a good square.
If every interior angle of polygon is less than degrees, then shape is called a strictly convex polygon.
The detailed subtask constraints are as follows: | Subtask ID | Constraints | Score | | :-: | :-: | :-: | | 1 | and are good rectangles, and all input point coordinates are within | | | 2 | is a good rectangle and , is a good square | | | 3 | are good rectangles | | | 4 | is a triangle, is a good square | | | 5 | are triangles | | | 6 | is a strictly convex polygon, is a good rectangle | | | 7 | is a good rectangle | | | 8 | No special constraints | |
Notes
This problem is translated from Central-European Olympiad in Informatics 2019 Day 2 T3 Scissors and Tape。
Translated by ChatGPT 5
京公网安备 11011102002149号