#K63967. Matrix Subarray Updates
Matrix Subarray Updates
Matrix Subarray Updates
You are given an empty matrix of size $$N \times M$$, initially filled with zeros. Your task is to perform (K) update operations on this matrix. Each update is described by four integers (r_1, c_1, r_2, c_2) representing the top-left and bottom-right coordinates of a submatrix. For each update, add 1 to every cell within the submatrix defined by $$r_1 \leq i \leq r_2; \text{and}; c_1 \leq j \leq c_2$$ (here, the indices are 1-indexed). Finally, output the resulting matrix. This problem tests your ability to simulate matrix updates and manage multi-dimensional data.
inputFormat
Input is provided via standard input (stdin). The first line contains three space-separated integers: (N) (number of rows), (M) (number of columns), and (K) (number of updates). Following that, there are (K) lines, each containing four space-separated integers (r_1, c_1, r_2, c_2) representing an update operation on the submatrix.
outputFormat
Output the final state of the matrix to standard output (stdout). The output should consist of (N) lines, with each line containing (M) space-separated integers representing the updated matrix rows.## sample
3 3 2
1 1 2 2
2 2 3 3
1 1 0
1 2 1
0 1 1
</p>