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. error LNK2001: unresolved external symbol "public: virtual

    1) Mine solution : project-setting :static lib to shared dll .then ok. 找不到secondchar的定义, 你是否没有把包含sec ...

  2. 2016最热门的PHP框架(一共五款)

    摘要: 兄弟连IT教育作为全国最大的PHP培训机构,迄今已有10年的教育历史.6大特色课程:PHP编程.安卓培训.JAVAEE+大数据.UI设计.HTML5培训.云计算架构师,在目前IT市场特别火,每 ...

  3. 添加asp.net mvc到现有的asp.net web form 应用程序

    前言 asp.net mvc的前一版本为asp.net web Form(Asp.net mvc之前称为asp.net),其第一个版本与2002年年初发布.asp.net web form 属于.ne ...

  4. RMAN-03002、RMAN-06059

    使用RMAN备份的时候无法正常备份,抛出以下错误: RMAN-03002: failure of backup command at 04/20/2015 18:55:45 RMAN-06059: e ...

  5. 关于JS面向对象继承问题

    1.原型继承(是JS中很常用的一种继承方式) 子类children想要继承父类father中的所有的属性和方法(私有+公有),只需要让children.prototype=new father;即可. ...

  6. html练习(3)

    1.这个小练习用到了css的四种选择器id选择器,类选择器,html选择器,通配符选择器. (1)假设一个元素中用到了各种选择器,而且选择器中的属性发生了冲突,则 优先级为id选择器>类选择器& ...

  7. 卫星网络中使用TCP协议的劣势(所以才有TCP优化版用来卫星通信啊,比如TCP-Peach和ADolar)

    卫星网络中使用TCP协议的劣势 为了避免产生网络拥塞,原TCP协议综合采用了慢启动.拥塞避免.快速重传以及快速恢复等算法.但这些算法应用的前提是网络发生拥塞造成丢包,然而在误码率相对较高的卫星通信系统 ...

  8. 5DXTPlayer串口调试小结

    小结 过程总是艰难. 首先是没有准备好. 没有安装vs2012,安装的时候,出现各种状况,因为先安装的2013高版本,造成12安装不正确,程序编译出问题.没有办法,只好卸载vs2012,2013及其各 ...

  9. 【转】HTML5移动端最新兼容问题解决方案

    1.安卓浏览器看背景图片,有些设备会模糊. 用同等比例的图片在PC机上很清楚,但是手机上很模糊,原因是什么呢? 经过研究,是devicePixelRatio作怪,因为手机分辨率太小,如果按照分辨率来显 ...

  10. Perl自动释放Licence启动Verdi

    Perl自动释放Licence启动Verdi 在工作中,遇到verdi的License不够的情况,某些人占用了多个License,为及时获得一个可用的License,写了一个perl来kill运行时间 ...