Pocket Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2097 Accepted Submission(s): 761
Problem Description
The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube.
The cube consists of 8 pieces, all corners.
Each piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer.
For each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise.
You should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers.
Input
The first line of input contains one integer N(N ≤ 30) which is the number of test cases.
For each test case, the first line describes the top face of the pocket cube, which is the common 2 × 2 face of pieces
labelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces.
The second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers are
given corresponding to the above pieces.
The third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0),(0, 0, 0),(0, 1, 0). Four integers are
given corresponding to the above pieces.
The fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers are
given corresponding to the above pieces.
The fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are given
corresponding to the above pieces.
The six line describes the right face, the common face of (0, 1, 1),(0, 1, 0),(1, 1, 1),(1, 1, 0). Four integers are given
corresponding to the above pieces.
In other words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface development
as follows.
+ - + - + - + - + - + - +
| q | r | a | b | u | v |
+ - + - + - + - + - + - +
| s | t | c | d | w | x |
+ - + - + - + - + - + - +
| e | f |
+ - + - +
| g | h |
+ - + - +
| i | j |
+ - + - +
| k | l |
+ - + - +
| m | n |
+ - + - +
| o | p |
+ - + - +
Output
For each test case, output YES if can be restored in one step, otherwise output NO.
Sample Input
41 1 1 12 2 2 23 3 3 34 4 4 45 5 5 56 6 6 66 6 6 61 1 1 12 2 2 23 3 3 35 5 5 54 4 4 41 4 1 42 1 2 13 2 3 24 3 4 35 5 5 56 6 6 61 3 1 32 4 2 43 1 3 14 2 4 25 5 5 56 6 6 6
Sample Output
Source
2016ACM/ICPC亚洲区青岛站-重现赛(感谢中国石油大学)
Recommend
jiangzijing2015 | We have carefully selected several similar problems for you: 6297 6296 6295 6294 6293
题目的意思是2*2*2的魔方 要么不用旋转 6个面 每个面颜色一致 输出YES
要么只旋转一次 6个面 每个面颜色一致 输出YES
思路:1.魔方已经拼好了
2.魔方还差一次旋转 {因为就差一次旋转 所以有2个对面是已经颜色一致的}
{ 根据题目给的图
我们设 abcd 为 面1
efgh 为 面2
ijkl 为 面3
mnop 为 面4
qrst 为 面5
uvwx 为 面6
}
{
即 面1和面3 是一个对面
面2和面4 是一个对面
面5和面6 是一个对面
}
{
当1-3面不变的时候
我将图转换一下 如下
这应该是旋转之后的或者 6个面应该颜色相同的对应
如果要恢复到旋转之前 应该是有2个偏移(2个方向)
也就是
情况一:
{
r=t=g=h 、 e=f=x=v 、w=u=n=m、p=o=q=s
}
情况二:
{
r=t=n=m 、e=f=q=s、w=u=g=h、p=o=x=v
}
}
{
当2-4面不变的时候
我将图转换一下 如下
这应该是旋转之后的或者 6个面应该颜色相同的对应
如果要恢复到旋转之前 应该是有2个偏移(2个方向)
也就是
情况一:
{
t=s=k=l、i=j=v=u、x=w=b=a、d=c=r=q
}
情况二:
{
t=s=a=b、i=j=q=r 、x=w=l=k、 d=c=u=v
}
}
{
当5-6面不变的时候
如下
这应该是旋转之后的或者 6个面应该颜色相同的对应
如果要恢复到旋转之前 应该是有2个偏移(2个方向)
也就是
情况一:
{
a=c=f=h 、e=g=j=l 、i=k=n=p 、m=o=b=d
}
情况二:
{
a=c=n=p 、e=g=b=d 、i=k=f=h、 m=o=j=l
}
}
我的程序:
#include
#include
#include