QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 128 MB 満点: 130

#17005. SLIKA

統計

Mirko 刚刚安装了一个全新的画图程序。该程序支持 $K$ 种不同的颜色,用 $1$ 到 $K$ 的整数表示。所有作画都在一个大小为 $N \times N$ 的画布上进行。最开始,所有格子都是白色的(用 $1$ 表示)。

画布的左上角格子坐标为 $(0, 0)$。第一个坐标 $x$ 表示行号(向下递增),第二个坐标 $y$ 表示列号(向右递增)。

Mirko 最喜欢的消遣是使用命令 PAINT c x1 y1 x2 y2 绘制矩形棋盘图案,其中 $c$ 表示选择的颜色,$(x1, y1)$ 和 $(x2, y2)$ 分别是所绘制矩形的左上角和右下角格子的坐标。

矩形的左上角格子将被涂上所选颜色,而其余格子则由棋盘格图案决定。未被所选颜色覆盖的格子将保留其先前的颜色。例如,在白色画布上绘制红色棋盘图案后的效果如下所示:

Mirko 最近发现了两个额外的命令。他可以在任何时候使用富有创意的命令 SAVE 来保存他的画作,并在以后使用命令 LOAD x 重新加载它,其中 $x$ 是一个正整数,表示存档的序号(第 $x$ 次保存)。

不幸的是,程序崩溃了,Mirko 的画作永久丢失了。幸运的是,Mirko 保存了所有使用过的命令的日志。你能通过重建丢失的画作来帮助 Mirko 吗?

输入格式

输入的第一行包含三个正整数 $N$($1 \le N \le 1000$)、$K$($2 \le K \le 100\,000$)和 $M$($1 \le M \le 100\,000$,表示命令的数量)。

接下来的 $M$ 行,每行包含上述三种命令之一。输入中不会包含任何非法命令。

输出格式

输出必须包含 $N$ 行,每行包含 $N$ 个整数,表示画作中对应行格子的颜色。

样例

输入样例 1

4 3 2
PAINT 2 0 0 3 3
PAINT 3 0 3 3 3

输出样例 1

2 1 2 3
1 2 1 2
2 1 2 3
1 2 1 2

输入样例 2

3 3 4
PAINT 3 0 0 1 1
SAVE
PAINT 2 1 1 2 2
LOAD 1

输出样例 2

3 1 1
1 3 1
1 1 1

输入样例 3

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

输出样例 3

2 1 1
1 3 1
4 1 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.