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. ios 推断是qq,银行卡,手机号等等公用的方法。

    #import <Foundation/Foundation.h> typedef enum  {     IdentifierTypeKnown = 0,     IdentifierT ...

  2. Flask项目之手机端租房网站的实战开发(一)

    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 一丶项目介绍 产品:关于手机移动端的租房网站 角色:在这个产品中用户包括房东与房客 功能:房东可以在这个平台发布自己的房屋,房客可 ...

  3. Java Timer TimerTask Example(java Timer的例子)

    Java java.util.Timer is a utility class that can be used to schedule a thread to be executed at cert ...

  4. (素材源代码) 猫猫学IOS(五)UI之360等下载管理器九宫格UI

    猫猫分享,必须精品 先看效果 代码学习地址: 猫猫学IOS(五)UI之360等下载管理器九宫格UI 猫猫学IOS(五)UI之360等下载管理器九宫格UI http://blog.csdn.net/u0 ...

  5. swiper如何实现轮播嵌套轮播

    之所以要写这篇文章是因为插件有个bug,要改掉这个bug比较麻烦,所以就想了个折中的办法,绕过这个限制,方法千万条,功能干出来第一条,哈哈 最近做了个需求,效果图是这样的 第一个框是大轮播,第二个框是 ...

  6. 过滤input框中的特殊字符

    两种方式,我觉得是一样的效果,请看: var charFilter1 = function(str) { var pattern = new RegExp("[`~!@#$^&*() ...

  7. shiro简单配置(转)

    注:这里只介绍spring配置模式. 因为官方例子虽然中有更加简洁的ini配置形式,但是使用ini配置无法与spring整合.而且两种配置方法一样,只是格式不一样. 涉及的jar包 Jar包名称 版本 ...

  8. [Angular2 Animation] Basic animation

    @Component({ selector: 'app-courses', templateUrl: './courses.component.html', styleUrls: ['./course ...

  9. LoaderManager使用具体解释(一)---没有Loader之前的世界

    来源: http://www.androiddesignpatterns.com/2012/07/loaders-and-loadermanager-background.html 感谢作者Alex ...

  10. Win7长时间使用占用内存高问题记

    工作电脑Win7 64位,8G内存,没设置虚拟内存,连续运行几天,中间只是睡眠,今天在试用时总提示内存不足,看任务管理器已经把占用内存比较多的几个进程都结束掉了,但内存占用依旧是80%以上,eclip ...