#K35362. Fill Grid with Operations
Fill Grid with Operations
Fill Grid with Operations
You are given a grid with n rows and m columns initially filled with the character .
. You need to perform a sequence of k operations. Each operation is described by four integers: x1, y1, x2, y2
. For each operation, you should fill every cell in the subgrid defined by the top‐left cell (x1, y1)
and the bottom‐right cell (x2, y2)
(both inclusive) with the character X
. The grid indices are 1-indexed.
The subrectangle defined by the coordinates satisfies the conditions: $$1 \le x1 \le x2 \le n$$ $$1 \le y1 \le y2 \le m$$
After all operations have been performed in the given order, output the final grid, printing each row as a string.
inputFormat
The first line contains two integers n
and m
separated by a space, representing the number of rows and columns respectively.
The second line contains a single integer k
, the number of operations.
Each of the following k
lines contains four integers x1 y1 x2 y2
, describing an operation which fills the subrectangle from cell (x1, y1)
to cell (x2, y2)
with the character X
.
outputFormat
Output n
lines. Each line should be a string of length m
representing a row of the grid after performing all the operations.
3 3
1
1 1 2 2
XX.
XX.
...
</p>