QOJ.ac

QOJ

Limite de temps : 5 s - 10 s Limite de mémoire : 1024 MB Points totaux : 34

#5962. 不祥的 Omino

Statistiques

$N$-omino 是通过将 $N$ 个单位正方形沿边完全连接而成的二维形状。更正式地说,1-omino 是一个 $1 \times 1$ 的单位正方形,而 $N$-omino 是一个 $(N-1)$-omino 与一个或多个相邻的 $1 \times 1$ 单位正方形连接而成的形状。在本题中,如果一个 $N$-omino 可以通过翻转和/或旋转变换为另一个,则认为它们是相同的。例如,以下是 5 种可能的 4-omino:

以下是 108 种可能的 7-omino 中的一部分:

Richard 和 Gabriel 将针对预先确定的 $X$、$R$ 和 $C$ 值进行一场游戏,规则如下:

  1. Richard 将选择任意一个可能的 $X$-omino。
  2. Gabriel 必须使用至少一个该 $X$-omino 的副本,以及任意数量的任意 $X$-omino 的副本(可以包括 Richard 选择的那个),来完全填满一个 $R \times C$ 的网格,且不能有重叠或溢出。也就是说,每个格子必须恰好被构成 $X$-omino 的 $X$ 个单元格中的一个覆盖,且没有任何 $X$-omino 可以超出网格范围。Gabriel 可以根据需要旋转或翻转任意数量的 $X$-omino,包括 Richard 选择的那个。如果 Gabriel 能完全填满网格,则他获胜;否则,Richard 获胜。

给定特定的 $X$、$R$ 和 $C$ 值,Richard 是否能选择一个 $X$-omino 来确保他获胜,还是无论 Richard 选择什么,Gabriel 都保证获胜?

输入格式

输入的第一行包含测试用例的数量 $T$。接下来有 $T$ 行,每行包含三个用空格分隔的整数:$X$、$R$ 和 $C$。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是测试用例编号(从 1 开始),$y$ 为 RICHARD(如果存在至少一种选择能确保 Richard 获胜)或 GABRIEL(如果无论 Richard 选择什么,Gabriel 都能获胜)。

数据范围

$1 \le T \le 100$ $1 \le X, R, C \le 20$

样例

样例输入 1

4
2 2 2
2 1 3
4 4 1
3 2 3

样例输出 1

Case #1: GABRIEL
Case #2: RICHARD
Case #3: RICHARD
Case #4: GABRIEL

说明

在案例 #1 中,Richard 只有一种 2-omino 可选——即由两个单位正方形连接而成的 $1 \times 2$ 块。无论 Gabriel 如何在 $2 \times 2$ 网格中放置该块,他都会留下一个可以用另一个 $1 \times 2$ 块完全填补的空洞。因此 Gabriel 获胜。

在案例 #2 中,Richard 必须选择 $1 \times 2$ 块,但无论 Gabriel 将其放在哪里,都会留下一个无法仅用 2-omino 填补的 $1 \times 1$ 空洞。因此 Richard 获胜。

在案例 #3 中,Richard 的一种获胜策略是选择 $2 \times 2$ 的正方形 4-omino。Gabriel 无法将该正方形放入 $4 \times 1$ 的网格中且使其完全包含在网格内,因此 Richard 获胜。

在案例 #4 中,Richard 可以选择直线的 3-omino 或 L 型的 3-omino。无论哪种情况,Gabriel 都能将其放入网格,并使用另一个相同的 3-omino 副本填补剩余的空洞。

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.