Line-Based Matrix Addition
시간 제한2초메모리 제한1024 MB
상승 대각선 구간과 하강 대각선 구간을 하나씩 골라 두 구간의 교집합에 속한 모든 칸에 값을 더하고, 최종 행렬을 출력한다.
문제
You are given an matrix .
Two types of lines exist on the matrix: rising and falling. There are lines for each type, where rising lines are numbered and falling lines are numbered for each . The below picture illustrates the line layout when .

You have to perform cumulative queries in order on this matrix, which is given by the input as:
- .
Each query specifies two line ranges of different types on the matrix, which is \left\\{ \mathrm{RL}\_i \mid s\_\mathrm{R} \le i \le e\_\mathrm{R} \right\\} and \left\\{ \mathrm{FL}\_i \mid s\_\mathrm{F} \le i \le e\_\mathrm{F} \right\\}, and a value . You should add the value to every element in the intersection of such range, i.e., \left\\{ \mathrm{RL}\_i \mid s\_\mathrm{R} \le i \le e\_\mathrm{R} \right\\} \quad \cap \quad \left\\{ \mathrm{FL}\_i \mid s\_\mathrm{F} \le i \le e\_\mathrm{F} \right\\}.
The following example illustrates the elements to update when , , and :

Write a program to perform the queries and output the final status of the matrix .
입력
The first line of input contains a single integer, , denoting the matrix size. ()
The next lines of input contain integers, where each line has space-separated integers, denoting the value of the matrix. Here, the -th integer of the -th line denotes . ()
The next line contains a single integer, , denoting the query count. ()
The -th of the next lines of input contain five space-separated integers: , , , , and , denoting the -th query explained earlier. ( )
출력
Output lines denoting the updated value of the matrix . Each line should contain space-separated integers. The -th integer of the -th line should represent .
힌트
(For Sogang students:) Note that this problem is an improvised version that matches the format of a problem in a general programming contest. While in the exam, the original scoring was:
- points for Subtask 1.
- points for Subtask 2.
- points for Subtask 3.
- points for Subtask 4.