#P7220. [JOISC 2020] 掃除
[JOISC 2020] 掃除
Description
Since Bitaro got AK at IOI, the IOI organizers gave him a house. The room is an isosceles right triangle with leg length . Any point in the room is represented by coordinates , where . The right-angle vertex is at the origin, and the two legs of the triangle are the -axis and the -axis.

One day, Bitaro found that he had already AK’ed IOIs, so he had nothing to do and decided to clean the dust in the room. Initially there are piles of dust, and the -th pile is at . Also, it is possible that multiple piles of dust are at the same position.
Now Bitaro is going to sweep the room using a broom. We model the broom as a line segment placed in the room, and we call the length of this segment the broom’s width. Since Bitaro is very organized, he will only clean the room in the following two ways:
-
Bitaro places the broom parallel to the -axis, with one endpoint at the origin. Then he moves the broom to the right perpendicularly until it cannot move any further. If the broom’s width is , then any dust pile originally at satisfying will be moved to . (There may be multiple dust piles at this position.) We call this operation process H.
-
Bitaro places the broom parallel to the -axis, with one endpoint at the origin. Then he moves the broom upward horizontally until it cannot move any further. If the broom’s width is , then any dust pile originally at satisfying will be moved to . (There may be multiple dust piles at this position.) We call this operation process V.
In Bitaro’s room, there will be events in order. The -th event is one of the following four types:
-
Bitaro wants to query the coordinates of the -th dust pile.
-
Bitaro uses a broom of width and performs process H.
-
Bitaro uses a broom of width and performs process V.
-
A new dust pile appears at point . If there are dust piles in total before this event, then this new pile is the -th dust pile in the room.
Since Bitaro has already AK’ed IOI and does not want to do anything, you need to write a program. Given the room’s leg length, the initial coordinates of each dust pile, and the details of each event, output the coordinates of the required dust piles.
Input Format
The first line contains three integers .
The next lines each contain two integers , representing the initial position of the -th dust pile.
The next lines each contain two or three integers, describing an event. Let be the first integer of the line. The meaning of each line is as follows:
-
If , then the line contains two integers , meaning Bitaro queries the coordinates of the -th dust pile.
-
If , then the line contains two integers , meaning Bitaro performs process H using a broom of width .
-
If , then the line contains two integers , meaning Bitaro performs process V using a broom of width .
-
If , then the line contains three integers , meaning a new dust pile appears at position .
Output Format
For each event with , output one line with two integers, representing the coordinates of the -th dust pile at the time event happens.
6 2 10
1 1
4 0
4 2 3
3 3
1 1
4 1 2
2 3
2 0
1 4
3 2
1 3
1 2
1 3
3 2
3 3
6 0
9 4 8
2 3
3 1
1 6
4 3
2 6
1 3
2 2
1 4
2 3
1 2
2 4
1 1
3 6
4 3
7 1
6 3
8 1 8
1 5
4 4 1
2 6
1 2
2 3
4 2 2
2 5
1 1
1 3
4 1
3 5
3 2
7 4 9
1 5
2 2
4 2
5 0
2 6
2 3
1 2
3 6
1 4
3 1
1 1
2 2
1 3
4 2
5 1
1 6
5 2
20 5 25
10 6
0 4
2 1
1 0
2 3
2 18
3 9
4 1 5
4 0 2
3 10
4 3 3
3 3
2 9
4 9 1
3 12
1 4
3 19
1 3
1 9
2 1
1 7
1 6
4 3 3
1 10
1 1
1 5
2 0
1 2
2 2
1 7
2 17
2 17
9 8
0 17
1 17
3 3
10 10
2 17
2 17
0 17
Hint
Sample 1 Explanation
At the beginning, the first dust pile is at and the second dust pile is at . Figure 1 shows the current state of the room.

In the first event, the third dust pile is added at . Figure 2 shows the current state of the room.

In the second event, Bitaro performs process V with a broom of width . After that, the first dust pile moves to . Figure 3 shows the current state of the room.

In the third event, Bitaro queries the coordinates of the first dust pile, which are .
In the fourth event, the fourth dust pile is added at . Figure 4 shows the current state of the room.

In the fifth event, Bitaro performs process H with a broom of width . The first dust pile moves to , the third dust pile moves to , and the fourth dust pile moves to . Figure 5 shows the current state of the room.

In the sixth event, Bitaro performs process H with a broom of width . The second dust pile moves to . Figure 6 shows the current state of the room.

In the seventh event, Bitaro queries the coordinates of the fourth dust pile, which are .
In the eighth event, Bitaro performs process V with a broom of width , but nothing happens. Figure 7 shows the current state of the room.

In the ninth event, Bitaro queries the coordinates of the third dust pile, which are .
In the tenth event, Bitaro queries the coordinates of the second dust pile, which are .
This sample satisfies the limits of Subtask 1 and Subtask 5.
Sample 2 to 5 Explanation
The second sample satisfies the limits of Subtask 1, 2, 4, and 5.
The third sample satisfies the limits of Subtask 1, 2, and 5.
The fourth sample satisfies the limits of Subtask 1, 3, 4, and 5.
The fifth sample satisfies the limits of Subtask 1 and Subtask 5.
Subtasks
| Subtask ID | Special Property | Score |
|---|---|---|
| Subtask 1 | ||
| Subtask 2 | ||
| Subtask 3 | $T\in\{1,2,3\},X_i\leq X_{i+1},Y_i\geq Y_{i+1}(1\leq i\leq m-1)$ | |
| Subtask 4 | ||
| Subtask 5 | None |
For of the data, $1\leq n\leq 10^9,1\leq m\leq 5\times 10^5,1\leq Q\leq 10^6$. It is guaranteed that:
-
.
-
, where is the number of dust piles at the time event happens.
-
.
-
.
-
There is at least one event with .
Translated by ChatGPT 5
京公网安备 11011102002149号