QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#18493. 常见的瓷砖染色问题

Estadísticas

世上有很多关于染色和铺瓷砖的问题。本题也是其中之一,我们讨论 L-tromino(L-三格骨牌),它是由 3 个边长为 1 的正方形瓷砖拼接而成的 L 形图形。包括旋转在内,L-tromino 共有以下 4 种形状。

图 I.1: L-tromino

考虑一个由 $2^k \times 2^k$ 个瓷砖组成的正方形棋盘,其中 $k$ 是正整数。众所周知,无论从哪个位置移除一个瓷砖,我们都可以用不重叠的 L-tromino 恰好铺满剩下的部分。放置 L-tromino 的方法可能有很多种。

在这样放置 L-tromino 之后,我们希望给每个 L-tromino 染色,使得所有的 L-tromino 都是可区分的。如果一个 L-tromino 与所有与其共享边界的其他 L-tromino 颜色都不同,则称该 L-tromino 是可区分的。

由于这些 L-tromino 位于同一个平面上,根据著名的四色定理,仅使用 4 种颜色就可以对所有 L-tromino 进行染色以使它们可区分。有趣的是,无论移除哪一个位置的瓷砖,都存在一种放置方案,使得可以使用不超过 3 种颜色对所有 L-tromino 进行染色并使它们可区分。

给定棋盘的大小和被移除瓷砖的位置,请根据上述内容,求出一种放置并染色 L-tromino 的方案。

输入格式

第一行包含两个整数 $T$ 和 $k$,分别表示测试用例的总数和决定棋盘大小的整数。($1 \le T \le 2^{10}$,$1 \le k \le 10$)

$T \times 2^{2k}$ 不超过 $2^{22}$。

接下来的 $T$ 行中,每行包含两个由空格分隔的整数 $a$ 和 $b$,表示每个测试用例中被移除瓷砖的位置。($1 \le a, b \le 2^k$)

输出格式

对于每个测试用例,输出 $2^k$ 行,表示在由 $2^k \times 2^k$ 个瓷砖组成的棋盘中,移除第 $a$ 行第 $b$ 列的瓷砖后,L-tromino 的染色方案。其中第 $i$ 行表示棋盘第 $i$ 行的布局。

瓷砖的颜色用 abc 之一表示,被移除的瓷砖用 @ 表示。当然,共享边界的两个相邻 L-tromino 的颜色不能相同。

样例

输入样例 1

2 1
1 2
2 2

输出样例 1

a@
aa
bb
b@

输入样例 2

1 3
7 6

输出样例 2

bbccaacc
baacabbc
ccabcbaa
cabbccab
aaccaabb
bbcbbacc
bcabc@bc
ccaaccbb

说明

图 I.2:用红色实线表示的边界上,相邻的两个 L-tromino 颜色相同,因此是错误答案

图 I.3:在 $2^3 \times 2^3$ 的棋盘中,当 $a = 7, b = 6$ 时的一种可能正确答案

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.