#C10628. Final Grid State after Repainting Operations

    ID: 39854 Type: Default 1000ms 256MiB

Final Grid State after Repainting Operations

Final Grid State after Repainting Operations

Given an \(N \times M\) grid and \(K\) repaint operations, your task is to compute the final configuration of the grid after all operations are applied. Initially, the grid is provided with cells marked either as 0 or 1.

Each repaint operation is represented by three integers \(r\), \(c\), and \(v\), where \(r\) and \(c\) are the 0-indexed row and column indices respectively. If \(v = 1\), you should repaint the cell at position \((r, c)\) to black (represented by 1). If \(v = 0\), no change is made to the cell. Operations are applied sequentially.

Your final output must display the grid after processing all operations, with each row printed on a new line and cells separated by a single space.

inputFormat

The first line of input contains three integers \(N\), \(M\), and \(K\):

  • \(N\): number of rows in the grid.
  • \(M\): number of columns in the grid.
  • \(K\): number of repaint operations.

Following this, there are \(N\) lines each containing \(M\) integers representing the initial grid configuration.

Then, \(K\) lines follow. Each of these lines contains three integers \(r\), \(c\), and \(v\) describing a repaint operation.

outputFormat

Print the final grid configuration after applying all the repaint operations. Each row should be printed on a new line, with cell values separated by a single space.

## sample
3 3 4
0 0 0
0 0 0
0 0 0
0 1 1
2 2 1
0 1 0
1 1 1
0 1 0

0 1 0 0 0 1

</p>