QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 512 MB 총점: 100

#14385. 二阶魔方

통계

二阶魔方(Pocket Cube),也被称为 Mini Cube 或 Ice Cube,是三阶魔方在 $2 \times 2 \times 2$ 规模下的等价物。该魔方由 8 个角块组成。

每个角块由一个三维坐标 $(h, k, l)$ 标记,其中 $h, k, l \in \{0, 1\}$。魔方的六个面中的每一个面都包含四个小面,每个小面上都写有一个正整数。

在每一步中,你可以选择魔方的任意一个面,并将该面顺时针或逆时针旋转 90 度。

你需要判断是否可以在一步之内(即进行至多一次旋转)复原魔方。我们称一个二阶魔方已被复原,当且仅当每个面上的四个小面都拥有相同的整数。

输入格式

输入的第一行包含一个整数 $N$ ($N \le 30$),表示测试用例的数量。

对于每个测试用例:

  • 第一行描述魔方的顶面(top face),它是标记为 $(0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)$ 的角块的公共 $2 \times 2$ 面。给出对应上述角块的四个整数。
  • 第二行描述前面(front face),它是 $(1, 0, 1), (1, 1, 1), (1, 0, 0), (1, 1, 0)$ 的公共面。给出对应上述角块的四个整数。
  • 第三行描述底面(bottom face),它是 $(1, 0, 0), (1, 1, 0), (0, 0, 0), (0, 1, 0)$ 的公共面。给出对应上述角块的四个整数。
  • 第四行描述后面(back face),它是 $(0, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1)$ 的公共面。给出对应上述角块的四个整数。
  • 第五行描述左面(left face),它是 $(0, 0, 0), (0, 0, 1), (1, 0, 0), (1, 0, 1)$ 的公共面。给出对应上述角块的四个整数。
  • 第六行描述右面(right face),它是 $(0, 1, 1), (0, 1, 0), (1, 1, 1), (1, 1, 0)$ 的公共面。给出对应上述角块的四个整数。

换句话说,每个测试用例包含 24 个整数,分别对应 $a, b, c$ 到 $x$。你可以将魔方的表面展开,得到如下的网格展开图:

+-+-+-+-+-+-+
| q | r | a | b | u | v |
+-+-+-+-+-+-+
| s | t | c | d | w | x |
+-+-+-+-+-+-+
    | e | f |
    +-+-+
    | g | h |
    +-+-+
    | i | j |
    +-+-+
    | k | l |
    +-+-+
    | m | n |
    +-+-+
    | o | p |
    +-+-+

输出格式

对于每个测试用例,如果魔方可以在一步之内复原,输出 YES,否则输出 NO

样例

输入样例 1

4
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
6 6 6 6
1 1 1 1
2 2 2 2
3 3 3 3
5 5 5 5
4 4 4 4
1 4 1 4
2 1 2 1
3 2 3 2
4 3 4 3
5 5 5 5
6 6 6 6
1 3 1 3
2 4 2 4
3 1 3 1
4 2 4 2
5 5 5 5
6 6 6 6

输出样例 1

YES
YES
YES
NO

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.