#P7636. [COCI 2010/2011 #5] SLIKA
[COCI 2010/2011 #5] SLIKA
Description
Mirko has just installed a brand new drawing program. The program supports different colors, represented by integers from to . All drawings are made on a canvas of size . At the beginning, all cells are white (represented by 1).
The cell in the top-left corner of the canvas has coordinates . The first coordinate denotes the row, and the second coordinate denotes the column.
Mirko’s favorite pastime is drawing a rectangular chessboard pattern using the command PAINT c x1 y1 x2 y2, where is the chosen color, and and are the top-left and bottom-right coordinates, respectively.
The top-left cell of the rectangle will be painted with the chosen color, and the rest will be colored like a chessboard. Cells not covered by the chosen color will keep their previous color.
For example, a white canvas painted with a red chessboard pattern looks like this:

Mirko recently discovered two more commands. He can save his drawing at any time using the SAVE command, and later load it again using the command load x, where is a positive integer representing the save index.
Unfortunately, the program crashed, and Mirko’s drawing was lost forever. Fortunately, Mirko has a log that contains all commands that were used. Can you help Mirko restore the lost drawing?
Input Format
The first line contains three positive integers . is the side length of the canvas, means there are colors, and is the number of commands.
Each of the next lines contains one of the three commands described above. The input will not contain any invalid commands.
Output Format
Output lines. Each line should contain integers representing the colors of the cells in that row of the final drawing.
4 3 2
PAINT 2 0 0 3 3
PAINT 3 0 3 3 3
2 1 2 3
1 2 1 2
2 1 2 3
1 2 1 2
3 3 4
PAINT 3 0 0 1 1
SAVE
PAINT 2 1 1 2 2
LOAD 1
3 1 1
1 3 1
1 1 1
3 4 7
PAINT 2 0 0 1 1
SAVE
PAINT 3 1 1 2 2
SAVE
PAINT 4 0 2 0 2
LOAD 2
PAINT 4 2 0 2 0
2 1 1
1 3 1
4 1 3
Hint
Sample Explanation #1
Command paints the cells from to in a chessboard pattern, meaning it paints , , , , , , , with color .
Command paints the cells from to in a chessboard pattern, meaning it paints and with color .
Constraints
For of the testdata, , , .
Notes
The score of this problem follows the original COCI settings, with a full score of .
This problem is translated from COCI2010-2011 CONTEST #5 T6 SLIKA.
Translated by ChatGPT 5
京公网安备 11011102002149号