QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100

#11776. 数独的等价性

Statistiques

数独解是一个 $9 \times 9$ 的矩阵,其中数字 $1$ 到 $9$ 在每一行、每一列和每一个 $3 \times 3$ 的宫格中都只出现一次。给定一个数独解 $S$,通过执行一个或多个基本变换,可以很容易地生成许多其他等价的解:$R$ 表示旋转 $90$、$180$ 或 $270$ 度,$M$ 表示沿水平或垂直轴翻转的镜像,$B$ 表示将数字 $1$ 到 $9$ 双射映射到另一组数字 $1$ 到 $9$ 的置换。在下例中,可以看出 $S_1$、$S_2$ 和 $S_3$ 都与 $S$ 等价。

部分数独是指并非所有 $81$ 个单元格都已填满的数独。如果存在一个与 $P_2$ 等价的矩阵 $P$,且 $P$ 可以通过在 $P_1$ 中填充一个或多个单元格得到,则称部分数独 $P_1$ 被另一个部分数独 $P_2$ 包含(小于)。在下例中,$P_1$ 被 $P_2$ 包含(相对于 $P$),其中 $P$ 可以通过将 $P_2$ 顺时针旋转 $90$ 度,并应用双射映射 $\{1, 2, 3, 4, 5, 6, 7, 8, 9\} \to \{2, 9, 3, 7, 8, 6, 1, 5, 4\}$ 得到。类似地,我们称 $P_2$ 包含 $P_1$,或者相对于 $P$ 而言 $P_2$ 大于 $P_1$。注意,矩阵不一定需要完全填满。

总结来说,在任意两个数独矩阵 $S_1$ 和 $S_2$ 之间,存在四种可能的关系:$S_1$ 与 $S_2$ 等价 ($E$),$S_1$ 小于 $S_2$ ($L$),$S_1$ 大于 $S_2$ ($G$),$S_1$ 与 $S_2$ 不可比 ($I$)。编写一个程序,读入 $n$ 个数独矩阵列表,并确定它们之间的两两关系。输出为一个 $n \times n$ 的矩阵,显示这些关系 ($E, L, G, I$)。显然,对角线元素均为 $E$(每个矩阵显然都与自身等价)。

输入格式

第一行包含矩阵的数量 $n$。随后的每一组 $9$ 行对应一个(部分)数独矩阵。未填写的单元格用 $0$ 表示(而不是空格)。假设 $2 < n \le 400$,所有输入均正确,且所有矩阵均为合法的(部分)数独矩阵。

输出格式

对于每一对输入矩阵,确定它们之间的关系,并将该关系输出为单个字母 $O \in \{E, L, G, I\}$。每个输入矩阵对应一行输出。

样例

输入 1

3
074523098
000798140
598040237
630279580
847056923
025084001
486910352
219835076
053402800
008050470
615200980
030900502
000671090
460892000
900000001
102089765
806514239
009720140
174523098
302790145
598040237
630079584
847056903
925384760
486900352
219035476
053400819

输出 1

EGI
LEL
IGE

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.