#C5529. Black Cell Grid Painting
Black Cell Grid Painting
Black Cell Grid Painting
You are given an \( n \times m \) grid, where each cell is initially white. You will be given \( k \) operations, each described by three integers \( t \), \( x \), and \( y \). The operations are defined as follows:
- \( t = 0 \): Paint the cell at row \( x \) and column \( y \) black.
- \( t = 1 \): Paint the cell at row \( x \) and column \( y \) white.
After performing all operations, output the total number of black cells and, on subsequent lines, the coordinates of each black cell. The coordinates must be sorted in lexicographical order (first by row and then by column). Note that the grid uses 0-indexed rows and columns.
inputFormat
The first line contains three integers ( n ), ( m ), and ( k ) separated by spaces. Each of the following ( k ) lines contains three integers ( t ), ( x ), and ( y ) separated by spaces, representing one operation.
outputFormat
Output the total number of black cells on the first line. For each black cell, output a line with its row and column separated by a space, sorted in lexicographical order. If there are no black cells, only output 0.## sample
3 3 5
0 0 0
0 1 1
1 0 0
0 2 2
0 0 1
3
0 1
1 1
2 2
</p>