【】【】Pocket Cube
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的更多相关文章
- 【poj 1988】Cube Stacking(图论--带权并查集)
题意:有N个方块,M个操作{"C x":查询方块x上的方块数:"M x y":移动方块x所在的整个方块堆到方块y所在的整个方块堆之上}.输出相应的答案. 解法: ...
- 【SIGGRAPH】【最终幻想XV】的战斗场景实时演示的要点解说
[SIGGRAPH][最终幻想XV]的战斗场景实时演示的要点解说 原文:西川善司 http://www.4gamer.net/games/999/G999902/20160730004/ ...
- 【Unity Shaders】学习笔记——SurfaceShader(十一)光照模型
[Unity Shaders]学习笔记——SurfaceShader(十一)光照模型 转载请注明出处:http://www.cnblogs.com/-867259206/p/5664792.html ...
- 【Unity Shaders】学习笔记——SurfaceShader(九)Cubemap
[Unity Shaders]学习笔记——SurfaceShader(九)Cubemap 如果你想从零开始学习Unity Shader,那么你可以看看本系列的文章入门,你只需要稍微有点编程的概念就可以 ...
- 【Unity Shaders】学习笔记——SurfaceShader(一)认识结构
[Unity Shaders]学习笔记——SurfaceShader(一)认识结构 转载请注明出处:http://www.cnblogs.com/-867259206/p/5595747.html 写 ...
- 【开发必备】吐血推荐珍藏的Chrome插件
[开发必备]吐血推荐珍藏的Chrome插件 一:(Lying人生感悟.可忽略) 青春浪漫,往往难敌事故变迁.生命对每一个人都是平等的,彼此所经历的那就一定是彼此所必须经历的,它一定不是只为了折磨.消耗 ...
- 【ASP.NET】判断访问网站的客户端是PC还是手机
原文:[ASP.NET]判断访问网站的客户端是PC还是手机 主要就是通过客户端传递的User-agent来判断访问网站的客户端是PC还是手机,.NET中就是Request.ServerVariable ...
- 【Unity Shader】(五) ------ 透明效果之半透明效果的实现及原理
笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题 [Unity Shader学习笔记](三) -- ...
- 【Unity Shader】(九) ------ 高级纹理之渲染纹理及镜子与玻璃效果的实现
笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题. [Unity Shader](三) ----- ...
随机推荐
- oled的一套stm32实验1
详细的oled介绍:http://blog.sina.com.cn/s/blog_57ad1bd20102wtq8.html 整理自:https://www.cnblogs.com/wp2312139 ...
- Javascript和jquery事件--滚动条事件和自定义滚动条事件样式
很想把滚动条事件跟鼠标滚轮事件放在一起,那就直接写在这一篇了.除了事件以外,对滚动条样式的调整也记在这里吧. 滚动条是浏览器的默认事件,使用overflow:auto/scroll都有可能出现,它的默 ...
- css页面滚动条出现时防止页面跳动的方法
大家写页面时应该都遇到过一个问题,尤其是写单页面应用的时候, 在有滚动条页面和没有滚动条页面之间相互跳转时, 你页面的主体内容会向左或者向右抖一下,让强迫症看了很不舒服. 现在就来解救一下强迫症: 方 ...
- Day3:集合
一.集合的定义及特性 1.集合的特性 1.1 去重,把一个列表变成集合,就自动去重了 1.2 关系测试,测试两组数据之间的交集.差集等关系 #!/usr/bin/env python # -* ...
- Day2:列表、元组
一.列表 1.定义与访问元素(按索引) #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan list_a = [&quo ...
- 飞镖忍者 quick-cocos2d-x3.2
经典的入门小游戏.这里用quick-cocos2d-x3.2又一次写一遍,以便熟悉下quick 首先,创建project,假设不会自行百度啊. 1.编译效果例如以下: watermark/2/text ...
- 连接mongodb,kafka异步处理代码
1. mongodb异步处理 依赖: <dependencies> <dependency> <groupId>org.mongodb</groupId> ...
- 【例题 6-10 UVA - 699】The Falling Leaves
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 递归模拟就好. [代码] #include <bits/stdc++.h> using namespace std; c ...
- IQMath是什么 浮点转定点运算,dsp
[转帖注明出处:blog.csdn.net/lanmanck] 网上搜了一下没发现非常合适的,特写出来与大家分享. 大家都知道嵌入式系统里带浮点运算指令的CPU都比較少,TI的DSP也是定点的廉价. ...
- MVC模式编程演示样例-登录验证(静态)
好,上篇博客分享了本人总结的JSP-Servlet-JavaBean三层架构编程模式的实现思想和基本流程,接下来给大家分享一个MVC编程模式的实现演示样例-登录验证的过程,这里我仍然用的是静态的验证u ...