#K64022. Grid Operations on a Matrix
Grid Operations on a Matrix
Grid Operations on a Matrix
You are given a matrix (grid) with n rows and m columns initialized with zeros. You will also be provided with a sequence of operations to modify the grid. There are two types of operations:
- Type 1 (Set Operation): Given 4 integers: \(1\; x\; y\; v\). For every cell \((i,j)\) with \(x \le i \le n\) and \(y \le j \le m\), set the cell's value to \(v\).
- Type 2 (Increment Operation): Given 5 integers: \(2\; x_1\; y_1\; x_2\; y_2\). For every cell \((i,j)\) with \(x_1 \le i \le x_2\) and \(y_1 \le j \le y_2\), increase its value by 1.
Your task is to apply all operations in the given order and then output the final state of the grid.
Note: The grid uses 1-based indexing.
inputFormat
The input is read from stdin and has the following format:
- The first line contains two integers \(n\) and \(m\) \( (1 \leq n, m \leq \text{some limit})\), representing the number of rows and columns respectively.
- The second line contains a single integer \(k\), the number of operations.
- The following \(k\) lines each describe an operation. Each operation starts with an integer which is either 1 or 2. If the operation is type 1, the line contains:
1 x y v
. If the operation is type 2, the line contains:2 x1 y1 x2 y2
.
outputFormat
Output to stdout the final state of the grid. Print each row on a new line with the cell values separated by a space.
## sample3 3
1
1 1 1 5
5 5 5
5 5 5
5 5 5
</p>