#K15536. Grid Operation Application
Grid Operation Application
Grid Operation Application
You are given a grid with (R) rows and (C) columns. Initially, every cell in the grid is set to 0. You have to perform (Q) operations on this grid. Each operation is described by five integers (r_1), (c_1), (r_2), (c_2), and (V). For each operation, you need to add the value (V) to every cell in the subgrid whose top left cell is ((r_1, c_1)) and bottom right cell is ((r_2, c_2)).
The task is to compute the final grid after all operations have been applied. The cells are 1-indexed.
Example: For (R = 3), (C = 3), (Q = 2) and operations:
- \(1\ 1\ 2\ 2\ 5\)
- \(2\ 2\ 3\ 3\ 10\)
5 5 0 5 15 10 0 10 10
inputFormat
The first line contains three integers (R), (C), and (Q) separated by spaces, where (R) and (C) denote the number of rows and columns of the grid respectively, and (Q) is the number of operations. Each of the next (Q) lines contains five integers (r_1), (c_1), (r_2), (c_2), and (V) describing an operation.
outputFormat
Output the final grid after performing all operations. Print (R) lines, each containing (C) space-separated integers representing the values in the grid.## sample
3 3 2
1 1 2 2 5
2 2 3 3 10
5 5 0
5 15 10
0 10 10
</p>