luogu#P12016. [NOISG 2025 Finals] Thumper
[NOISG 2025 Finals] Thumper
题目描述
Bunnyland has large fields where the Bunnyland Dwarf (a native species of rabbit) roams freely. One such field can be modelled as a grid of cells. The rows of the grid are numbered to from north to south, and the columns of the grid are numbered to from west to east. We refer to the cell located at row and column of the grid as cell .
In this field, there are rabbits numbered from to . The -th rabbit is initially located at cell . No two rabbits are initially located at the same cell.
Rabbits lift their hind legs and kick the ground when annoyed, an action known as thumping. These rabbits will execute a sequence of thumps. At the start of the -th second, rabbit will thump. When a rabbit thumps, all other rabbits will move away from the thumping rabbit.
To be precise, when rabbit A thumps, rabbit B will move as follows:
- If the number of rows between A and B is less than the number of columns between A and B, B will move two columns away from A.
- If the number of rows between A and B is equal to the number of columns between A and B, B will move one column and one row away from A.
- If the number of rows between A and B is more than the number of columns between A and B, B will move two rows away from A.
It can be shown that the location of the rabbits will remain distinct after a thump has occurred.
Benson the Rabbit has come to find his brethren after his retirement from investigating toxic bacteria, but all the thumping has caused the rabbits to scatter. Help Benson determine the final locations of the rabbits after all thumps have occurred!
It is guaranteed that a rabbit will never leave the grid during the sequence of thumps. You may also assume that rabbits do not move in any other circumstances except thumping.
输入格式
Your program must read from standard input.
The first line of input contains two space-separated integers and .
The following lines of input each contain two space-separated integers. The -th of these lines contains and .
The last line of input contains space-separated integers .
输出格式
Your program must print to standard output.
The output should contain lines. The -th of these lines should contain two space-separated integers, indicating the row and the column of rabbit after all thumps have occurred.
2 1
1 1
2 2
1
1 1
3 3
13 1
7 7
3 7
4 4
4 10
5 6
6 4
6 8
8 7
8 10
9 3
9 5
9 9
10 6
1
7 7
1 7
3 3
3 11
3 6
6 2
5 9
10 7
8 12
9 1
10 4
10 10
12 6
3 2
1 10
1 20
1 30
1 3
1 8
1 20
1 32
提示
Subtasks
For all test cases, the input will satisfy the following bounds:
- for all
- for all
- for all
- It is guaranteed that a rabbit will never exit the grid during the sequence of thumps.
Your program will be tested on input instances that satisfy the following restrictions:
Subtask | Marks | Additional constraints |
---|---|---|
Sample test cases | ||
No additional constraints |
Sample Test Case 1 Explanation
This test case is valid for subtasks , and .
Rabbit is at cell and rabbit is at cell .
Since the number of rows between rabbit and rabbit is equal to the number of columns between rabbit and rabbit , when rabbit thumps, rabbit will move one column and one row away from rabbit in the southeast direction, landing at cell . The position of the thumping rabbit does not change.
Sample Test Case 2 Explanation
This test case is valid for subtasks , and .
The diagram in the statement corresponds to this test case. The blue arrows show how the other rabbits move when rabbit at cell thumps.
Sample Test Case 3 Explanation
This test case is valid for all subtasks.