Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 47 Accepted Submission(s): 12

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

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

Sample Output

YES

YES

YES

NO

【题目链接】:http://acm.split.hdu.edu.cn/contests/contest_showproblem.php?pid=1002&cid=737

【题解】



各个面在数组中的下标如下



然后让他旋转一次就好;

看看各个面是不是变成一样了;

不旋转也是可以的.



【完整代码】

#include <bits/stdc++.h>

using namespace std;

int c[6][4],temp[6][4];

bool ok(int a[6][4])
{
for (int i = 0;i <= 5;i++)
{
for (int j = 1;j <= 3;j++)
if (a[i][j]!=a[i][j-1])
return false;
}
return true;
} void fuzhi(int a[6][4],int b[6][4])
{
for (int i = 0;i <= 5;i++)
for (int j = 0;j <= 3;j++)
a[i][j] = b[i][j];
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
int T;
scanf("%d",&T);
while (T--)
{
for (int i = 0;i <= 5;i++)
for (int j = 0;j<= 3;j++)
scanf("%d",&c[i][j]),temp[i][j] = c[i][j];
if (ok(temp))
{
puts("YES");
continue;
}
int t0,t1;
fuzhi(temp,c);
temp[1][0] = temp[4][1],temp[1][1] = temp[4][3];
temp[4][3] = temp[3][2],temp[4][1] = temp[3][3];
temp[3][2] = temp[5][0],temp[3][3] = temp[5][2];
temp[5][0] = c[1][1],temp[5][2] = c[1][0];
if (ok(temp))
{
puts("YES");
continue;
}
fuzhi(temp,c);
temp[1][0] = temp[5][2],temp[1][1] = temp[5][0];
temp[5][2] = temp[3][3],temp[5][0] = temp[3][2];
temp[3][3] = temp[4][1],temp[3][2] = temp[4][3];
temp[4][1] = c[1][0],temp[4][3] = c[1][1];
if (ok(temp))
{
puts("YES");
continue;
}
fuzhi(temp,c);
temp[1][1] = temp[0][1],temp[1][3] = temp[0][3];
temp[0][1] = temp[3][1],temp[0][3] = temp[3][3];
temp[3][1] = temp[2][1],temp[3][3] = temp[2][3];
temp[2][1] = c[1][1],temp[2][3] = c[1][3];
if (ok(temp))
{
puts("YES");
continue;
}
fuzhi(temp,c);
temp[1][1] = temp[2][1],temp[1][3] = temp[2][3];
temp[2][1] = temp[3][1],temp[2][3] = temp[3][3];
temp[3][1] = temp[0][1],temp[3][3] = temp[0][3];
temp[0][1] = c[1][1],temp[0][3] = c[1][3];
if (ok(temp))
{
puts("YES");
continue;
}
fuzhi(temp,c);
temp[5][2] = temp[0][2],temp[5][3] = temp[0][3];
temp[0][2] = temp[4][2],temp[0][3] = temp[4][3];
temp[4][2] = temp[2][1],temp[4][3] = temp[2][0];
temp[2][1] = c[5][2],temp[2][0] = c[5][3];
if (ok(temp))
{
puts("YES");
continue;
}
fuzhi(temp,c);
temp[5][2] = temp[2][1],temp[5][3] = temp[2][0];
temp[2][1] = temp[4][2],temp[2][0] = temp[4][3];
temp[4][2] = temp[0][2],temp[4][3] = temp[0][3];
temp[0][2] = c[5][2],temp[0][3] = c[5][3];
if (ok(temp))
{
puts("YES");
continue;
}
puts("NO");
}
return 0;
}

【】【】Pocket Cube的更多相关文章

  1. 【poj 1988】Cube Stacking(图论--带权并查集)

    题意:有N个方块,M个操作{"C x":查询方块x上的方块数:"M x y":移动方块x所在的整个方块堆到方块y所在的整个方块堆之上}.输出相应的答案. 解法: ...

  2. 【SIGGRAPH】【最终幻想XV】的战斗场景实时演示的要点解说

    [SIGGRAPH][最终幻想XV]的战斗场景实时演示的要点解说 原文:西川善司 http://www.4gamer.net/games/999/G999902/20160730004/        ...

  3. 【Unity Shaders】学习笔记——SurfaceShader(十一)光照模型

    [Unity Shaders]学习笔记——SurfaceShader(十一)光照模型 转载请注明出处:http://www.cnblogs.com/-867259206/p/5664792.html ...

  4. 【Unity Shaders】学习笔记——SurfaceShader(九)Cubemap

    [Unity Shaders]学习笔记——SurfaceShader(九)Cubemap 如果你想从零开始学习Unity Shader,那么你可以看看本系列的文章入门,你只需要稍微有点编程的概念就可以 ...

  5. 【Unity Shaders】学习笔记——SurfaceShader(一)认识结构

    [Unity Shaders]学习笔记——SurfaceShader(一)认识结构 转载请注明出处:http://www.cnblogs.com/-867259206/p/5595747.html 写 ...

  6. 【开发必备】吐血推荐珍藏的Chrome插件

    [开发必备]吐血推荐珍藏的Chrome插件 一:(Lying人生感悟.可忽略) 青春浪漫,往往难敌事故变迁.生命对每一个人都是平等的,彼此所经历的那就一定是彼此所必须经历的,它一定不是只为了折磨.消耗 ...

  7. 【ASP.NET】判断访问网站的客户端是PC还是手机

    原文:[ASP.NET]判断访问网站的客户端是PC还是手机 主要就是通过客户端传递的User-agent来判断访问网站的客户端是PC还是手机,.NET中就是Request.ServerVariable ...

  8. 【Unity Shader】(五) ------ 透明效果之半透明效果的实现及原理

    笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题 [Unity Shader学习笔记](三) -- ...

  9. 【Unity Shader】(九) ------ 高级纹理之渲染纹理及镜子与玻璃效果的实现

    笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题. [Unity Shader](三) ----- ...

随机推荐

  1. 【CS Round #46 (Div. 1.5) B】Letters Deque

    [链接]h在这里写链接 [题意] 让你把一个正方形A竖直或水平翻转. 问你翻转一次能不能把A翻转成B [题解] 有说一定要恰好为1次. 并不是说A和B相同就一定不行. [错的次数] 2 [反思] 自己 ...

  2. 洛谷 P2646 数数zzy

    P2646 数数zzy 题目描述 zzy自从数学考试连续跪掉之后,上数学课就从来不认真听了(事实上他以前也不认真听).于是他开始在草稿纸上写写画画,比如写一串奇怪的字符串.然后他决定理♂性♂愉♂悦♂一 ...

  3. 中英文对照 —— 标点符号(punctuation)

    有限的几个: What Are the Fourteen Punctuation Marks in English Grammar? period:句号:comma:逗号:冒号:colon:分号:se ...

  4. 网站图标——favicon

    首先推荐一个网站图标在线制作工具favicon: 插入图标只需在head中间加入以下代码: <link rel="icon" href="img/favicon.i ...

  5. Java基础学习总结(28)——Java对各种排序算法的实现

    这里总结下各种排序算法的java实现 冒泡排序 public class BubbleSort { publicstaticint[] bubbleSort(int[] array) { if(arr ...

  6. 最全Pycharm教程(42)——Pycharm扩展功能之Emacs外部编辑器

    1.主题 介绍怎样将Emacs定义为一个Pycharm外部编辑器. 2.准备工作 (1)Pycharm版本号为2.7或更高 (2)下载了downloadedEmacs并正确安装 3.配置Emacs 打 ...

  7. 在此页上的 ActiveX 控件和本页上的其它部份的交互可能不安全

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息http://xqy266.blogbus.com/logs/66258230.html 在EOS6的项目中,如果采用VC++开发的Active ...

  8. 【42.86%】【Codeforces Round #380D】Sea Battle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. [AngularFire2] Auth with Firebase auth -- email

    First, you need to enable the email auth in Firebase console. Then implement the auth service: login ...

  10. iOS Universal Static Framework 手动转 XCode Cocoa Framework

    不须要又一次创建Project,手动改动project设置. 第一步:在Project文件里,改动type,去掉static 1. 搜索wrapper.framework.static,去掉stati ...