Color board - MarisaOJ: Marisa Online Judge

Color board

Time limit: 1000 ms
Memory limit: 256 MB
Alice has a grid of size $m \times n$, with rows numbered from $1$ to $m$ from top to bottom, and columns numbered from $1$ to $n$ from left to right. The cell at the intersection of row $i$ ($1 \leq i \leq m$) and column $j$ ($1 \leq j \leq n$) is called cell $(i, j)$. Initially, the entire grid is white (color $0$). Alice performs $k$ coloring operations as follows: - She selects a rectangle within the grid, occupying a set of contiguous cells, and chooses a color $c$ ($1 \leq c < 100$); - She then overwrites all cells within the selected rectangle to color $c$. **Objective:** Given the grid dimensions $m$ and $n$ and a sequence of $k$ coloring operations, determine the resulting color grid that Alice obtains. ### Input - The first line contains three integers $m$, $n$, and $k$ ($m, n, k \leq 100$); - The $s$-th line ($1 \leq s \leq k$) contains five integers $x_s, y_s, u_s, v_s, c_s$, where $(x_s, y_s)$ and $(u_s, v_s)$ are the coordinates of the top-left and bottom-right corners of the selected rectangle for the $s$-th coloring operation, and $c_s$ is the color to fill that rectangle. ### Output - The $i$-th line ($1 \leq i \leq m$) in the next $m$ lines contains $n$ integers $a_{i1}, a_{i2}, \ldots, a_{in}$ describing the colors in row $i$ of Alice's color grid. ### Constraints - $1 \le T \le 10^5$. - $1 \le n \le 10^6$. - $0 \le |a_i| < 10^6$. ### Example Input: ``` 3 3 2 1 1 2 2 2 2 2 3 3 1 ``` Output: ``` 2 2 0 2 1 1 0 1 1 ```