CF887C.Solution for Cube

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.

It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.

To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.

Cube is called solved if for each face of cube all squares on it has the same color.

https://en.wikipedia.org/wiki/Rubik's_Cube

在比赛间隙,顶级模特伊莎贝拉努力提升自我、避免无聊。例如,她现在正尝试解决 2×2×2 的魔方。

立即学会解魔方太难了,因此她转而学习判断:给定魔方的某一状态,是否仅通过一次 90 度旋转(任一方向)某一面,即可将其还原。

为了验证自己的答案,她希望借助一个程序:该程序接收魔方的某一状态作为输入,并判断是否能通过上述所描述的一次旋转将其还原。

当魔方每个面的所有小方块颜色均相同时,称该魔方为“已还原”。

https://en.wikipedia.org/wiki/Rubik's_Cube

输入格式

In first line given a sequence of 24 integers a__i (1 ≤ a__i ≤ 6), where a__i denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.

第一行给出一个由 24 个整数 aia_i(1≤ai≤61 \le a_i \le 6)组成的序列,其中 aia_i 表示第 ii 个方格的颜色。该序列中每种颜色恰好出现 4 次。

输出格式

Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.

如果可以通过一次旋转解决魔方,则输出 «YES»(不带引号);否则输出 «NO»(不带引号)。

输入输出样例

  • 输入#1

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

    输出#1

    NO
  • 输入#2

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

    输出#2

    YES

说明/提示

In first test case cube looks like this:

In second test case cube looks like this:

It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.

第一个测试用例中的魔方如下所示:

第二个测试用例中的魔方如下所示:

可以通过旋转标有数字 13、14、15、16 的面来还原该魔方。

输入解题思路,AI测评打分。不知道怎么写?

首页