#C11128. Matrix Recoloring Challenge
Matrix Recoloring Challenge
Matrix Recoloring Challenge
You are given a matrix A of size \(N \times M\). You will also be given \(Q\) queries. In each query, you are given five integers \(r_1, c_1, r_2, c_2, x\) that describe a submatrix whose upper-left corner is at \(A_{r_1,c_1}\) and lower-right corner is at \(A_{r_2,c_2}\) (0-indexed). Your task is to set every element in the specified submatrix to the new color \(x\).
After processing all queries, output the updated matrix. Each row should be printed on a separate line with the elements separated by a single space.
Note: The indices provided are 0-indexed.
inputFormat
The input is read from standard input (stdin) and has the following format:
N M A[0][0] A[0][1] ... A[0][M-1] A[1][0] A[1][1] ... A[1][M-1] ... A[N-1][0] A[N-1][1] ... A[N-1][M-1] Q r1 c1 r2 c2 x r1 c1 r2 c2 x ... r1 c1 r2 c2 x
Where the first line contains two integers \(N\) and \(M\), the dimensions of the matrix. The next \(N\) lines each contain \(M\) integers, representing the matrix elements. The following line contains the integer \(Q\) representing the number of queries. Each of the next \(Q\) lines contains five integers representing a query.
outputFormat
Output the final matrix to standard output (stdout). Each of the \(N\) lines should contain \(M\) integers separated by spaces, representing a row of the modified matrix.
## sample3 3
1 2 3
4 5 6
7 8 9
2
0 0 1 1 10
1 1 2 2 20
10 10 3
10 20 20
7 20 20
</p>