QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#11222. 熊猫先生与积木

统计

熊猫先生最近收到了一桶积木作为生日礼物。每块积木都是一个 $1 \times 1 \times 2$ 的长方体,由两个面面相接的 $1 \times 1 \times 1$ 的彩色小立方体组成。共有 $n$ 种颜色,标记为 $1, 2, \dots, n$。

熊猫先生检查了所有的积木,发现他恰好有 $\frac{n(n+1)}{2}$ 块积木,且每块积木都涂有唯一的一对颜色。也就是说,对于每一对颜色 $(i, j)$ ($1 \le i \le j \le n$),他都恰好有一块积木,其中一个小立方体颜色为 $i$,另一个颜色为 $j$。

熊猫先生今天计划用这些积木建造一座梦幻城堡。

首先,他定义了一个属性称为“连通”: 1. 如果立方体 A 与立方体 B 共享一个面,则它们是连通的。 2. 如果立方体 A 与立方体 B 连通,且立方体 B 与立方体 C 连通,则立方体 A 与立方体 C 连通。 3. 如果城堡中所有立方体两两连通,则该城堡是连通的。

然后他提出了以下要求: 1. 整个城堡应该是连通的。 2. 对于任何颜色 $i$,如果只考虑该颜色的立方体,由这些立方体组成的子城堡也应该是连通的。

然而,经过多次尝试,熊猫先生仍然无法建造出这样的城堡。所以他向你寻求帮助。你能帮熊猫先生建造一座满足他所有要求的城堡吗?

输入格式

第一行输入包含测试用例的数量 $T$ ($1 \le T \le 10$)。接下来是 $T$ 个测试用例。 对于每个测试用例,一行包含一个整数 $n$ ($1 \le n \le 200$),表示颜色的数量。

输出格式

对于每个测试用例,首先输出一行包含 “Case #x:”,其中 $x$ 是测试用例编号(从 1 开始)。

如果无法建造满足熊猫先生要求的城堡,输出一行 “NO”。

如果可以建造该城堡,首先输出一行 “YES”。 然后,输出 $\frac{n(n+1)}{2}$ 行描述所有积木的坐标。每一行应按 $i, j, x_i, y_i, z_i, x_j, y_j, z_j$ 的格式输出 ($1 \le i \le j \le n, 0 \le x_i, y_i, z_i, x_j, y_j, z_j \le 10^9$),这意味着对于积木 $(i, j)$,颜色为 $i$ 的立方体位于 $(x_i, y_i, z_i)$,颜色为 $j$ 的立方体位于 $(x_j, y_j, z_j)$。你需要确保每一对 $(i, j)$ 在你的答案中恰好出现一次。

如果有多种解,任何一种解都将被接受。

样例

输入 1

2
3
4

输出 1

Case #1:
YES
1 1 1 1 0 1 2 0
1 2 1 3 0 1 4 0
1 3 2 1 0 3 1 0
2 2 2 2 0 2 3 0
2 3 2 4 0 3 4 0
3 3 3 2 0 3 3 0
Case #2:
YES
1 2 1 3 0 1 4 0
1 1 1 2 0 1 1 0
1 3 2 1 0 2 2 0
2 3 2 4 0 2 3 0
1 4 3 1 0 4 1 0
3 3 3 2 0 3 3 0
2 2 3 4 0 3 4 1
4 4 4 2 0 5 2 0
3 4 4 3 0 5 3 0
2 4 4 4 0 5 4 0

Figure 1. 积木城堡示意图

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.