Matrix Addition
면접 대비시간 제한1초메모리 제한1024 MB
N x N 행렬에 Q개의 직사각형 덧셈 연산을 적용한 뒤 최종 행렬을 출력한다. 2차원 차분 배열로 빠르게 처리한다.
문제
You are given an matrix initialized with arbitrary values. You will receive operations, each defined by five values: . For each operation, you need to update the matrix by adding to all elements in the submatrix defined by the rows from to and the columns from to .
입력
The first line contains two integers and , the matrix size and the number of operations.
The next lines each contain integers, forming the initial matrix .
Each of the next lines contains five integers , describing an operation to add to every element in the submatrix with rows to and columns to (1-based indices, and .
출력
Print the resulting matrix after performing all operations: lines, each with integers separated by spaces.