#P15666. [ICPC 2025 Jakarta R] Down Right Chips
[ICPC 2025 Jakarta R] Down Right Chips
题目描述
You have a board of size , with rows numbered from to from top to bottom, and columns numbered from to from left to right. Initially, there are chips on the tile at the -th row and -th column.
You will play a solitaire game on this board. In one move, you can do one of the following.
- Choose a tile not in the bottommost row with at least two chips on it. Discard one chip from the tile, and move another chip to the tile directly below it.
- Choose a tile not in the rightmost column with at least one chip on it. Move one chip from the tile to the tile directly to its right.
The game ends when there are no more moves you can make.
There will be changes to the board, and each of the changes will chips to the tile at the -th row and -th column. After each change, calculate the minimum number of moves to end the game using the current board.
输入格式
The first line contains three integers , , and (; ).
The next lines, each containing integers, represent ().
Each of the next lines contains three integers , , and (; ; ) representing a change to the board.
输出格式
Output lines, each containing a single integer representing the minimum number of moves to end the game after each change.
2 3 2
0 2 1
0 1 1
1 2 1
2 3 5
5
5
提示
After the first change, you can play as follows for the minimum number of moves.
- Move on tile .
- Move on tile .
- Move on tile .
- Move on tile .
- Move on tile .