#P11113. Chessboard Operation Simulation
Chessboard Operation Simulation
Chessboard Operation Simulation
Given the initial state of a chessboard and a sequence of operations, determine the final state of the board after all operations have been performed. The board is represented by an R \times C
matrix, where each cell contains an integer.
Each operation is represented by three integers r, c, and v which indicates that the cell at row r and column c is updated to the value v. In mathematical terms, the operation is:
$$board[r][c] = v$$
Note: The indices r and c are 0-based.
inputFormat
The first line contains two space-separated integers R and C denoting the number of rows and columns of the board.
The next R lines each contain C integers representing the initial state of the board.
The following line contains a single integer Q denoting the number of operations.
Each of the next Q lines contains three space-separated integers r, c, and v, representing an operation that sets the value of board[r][c]
to v.
outputFormat
Output the final state of the board after executing all operations. Print R lines, each containing C space-separated integers.
sample
3 3
1 2 3
4 5 6
7 8 9
2
0 0 10
1 2 20
10 2 3
4 5 20
7 8 9
</p>