#P7862. Game
Game
Game
Problem Description
There are columns of blocks standing in a row. The -th column has blocks in the beginning. Each block has size . Define represent the block at column and is the -th block from bottom to top. You need to support two operations:
1 x y
Push one block to the left, that means you choose one block which has no block at its right and make it move to the left. Because of the friction, the block above it will also move to the left, and because the blocks cannot intersect, the block at its left will move to the left either. This will cause a chain reaction. After every block moved, if some blocks hang in the air, then it will fall because of gravitation. Note that the blocks at column can't move to the left, so if a movement causes a block at column move, you can't perform this operation. Formally, let be the number of blocks in the -th column now. If , you will do nothing. Otherwise, you will choose block . There are two stages of the movement of blocks. The first stage is moving. Let be the greatest position that satisfies and , then you can perform this operation as long as exists. Then for all blocks that satisfy and , it moves to . The second stage is falling. For blocks () that there are no blocks in , it falls to . Repeat doing it until no blocks satisfy the condition(There is a block in and no block in ). Output the number of blocks you have moved in this operation. If or you can't perform this problem, the answer is . It's not required that in this problem.This shows an operation that pushes the block at , and the value of is . The number of blocks moved is .
2 x
Ask the height of -th column now. You are also asked to output the height of all columns after all operations.
Input
The first line contains an integer - the number of test cases.
For each test case, the first line contains two integers . The second line contains integers . Each of the following lines contains an operation: 1 x y
(), or 2 x
.
Output
For each test case, output one integer in one line for each operation. Then output integers in one line - the height of all columns after all operations from left to right in order.
Sample Input
1
8 4
2 1 1 4 4 6 2 3
1 6 4
2 5
1 1 1
1 8 2
Sample Output
5
6
0
14
2 2 4 6 3 2 3 1
Source
2020 Multi-University Training Contest 9