시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB31272392.000%

문제

You are given an $N \times N$ matrix $A$ initialized with arbitrary values. You will receive $Q$ operations, each defined by five values: $R_1, C_1, R_2, C_2, V$. For each operation, you need to update the matrix by adding $V$ to all elements in the submatrix defined by the rows from $R_1$ to $R_2$ and the columns from $C_1$ to $C_2$.

입력

The first line contains two integers $N$ and $Q$, the matrix size and the number of operations. $(1 \leq N \leq 1\,000, 1 \leq Q \leq 200\,000)$

The next $N$ lines each contain $N$ integers, forming the initial matrix $A$. $(0 \leq A_{ij} \leq 100)$

Each of the next $Q$ lines contains five integers $R_1, C_1, R_2, C_2, V$, describing an operation to add $V$ to every element in the submatrix with rows $R_1$ to $R_2$ and columns $C_1$ to $C_2$ (1-based indices, and $1 \leq R_1 \leq R_2 \leq N, 1 \leq C_1 \leq C_2 \leq N, 0 \leq V \leq 100)$.

출력

Print the resulting matrix after performing all $Q$ operations: $N$ lines, each with $N$ integers separated by spaces.

서브태스크

번호배점제한
160

$1 \leq N \leq 1\,000, 1 \leq Q \leq 10$

220

$1 \leq N \leq 1\,000, 1 \leq Q \leq 10\,000$

320

$1 \leq N \leq 1\,000, 1 \leq Q \leq 200\,000$

예제 입력 1

4 2
0 0 0 5
0 0 0 0
0 0 0 0
0 0 0 0
1 1 3 2 1
2 2 4 4 2

예제 출력 1

1 1 0 5
1 3 2 2
1 3 2 2
0 2 2 2

This example satisfies the conditions of Subtask 1, 2 and 3.

채점 및 기타 정보

  • 예제는 채점하지 않는다.