Pocket Cube

http://acm.hdu.edu.cn/showproblem.php?pid=5983

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2852    Accepted Submission(s): 1066

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
 
Source

纯模拟= =,训练的时候脑抽没写出来

 #include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#define maxn 200005
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std; int map[][]; bool Check(){
int flag;
for(int i=;i<=;i++){
flag=map[i][];
for(int j=;j<=;j++){
if(flag!=map[i][j]){
return false;
}
}
}
return true;
} int _init_[][]; void init(){
for(int i=;i<=;i++){
for(int j=;j<=;j++){
map[i][j]=_init_[i][j];
}
}
} int main(){ int t;
cin>>t;
while(t--){
for(int i=;i<=;i++){
for(int j=;j<=;j++){
cin>>_init_[i][j];
}
}
int tmp1,tmp2;
init();
if(Check()){
cout<<"YES"<<endl;
continue;
}
//
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
//
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
//
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
init();
tmp1=map[][],tmp2=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=map[][],map[][]=map[][];
map[][]=tmp1,map[][]=tmp2;
if(Check()){
cout<<"YES"<<endl;
continue;
}
cout<<"NO"<<endl;
} }

Pocket Cube的更多相关文章

  1. 2013区域赛长沙赛区现场赛 K - Pocket Cube

    K - Pocket Cube Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  2. HDU 5292 Pocket Cube 结论题

    Pocket Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5292 Description Pocket Cube is the 2×2× ...

  3. 【】【】Pocket Cube

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s) ...

  4. 【HDOJ】4801 Pocket Cube 的几种解法和优化

    1. 题目描述给定一个$2 \times 2 \times 2$的魔方,当某个面上的4个小块颜色均相同时,称这个面为complete.求对这个魔方进行$n \in [1,7]$次旋转(沿某个面顺时针或 ...

  5. HDU 4801 Pocket Cube

    题目链接 去年现场,虎哥1Y的,现在刷刷题,找找状态... 一共6种转法,把3个面放到顶部,左旋和右旋,感觉写的还不错....都写成常数了. #include <stdio.h> #inc ...

  6. 模拟 ZOJ 3736 Pocket Cube

    题目传送门 题意:魔方最多旋转n次,问最多能使多少面颜色相同 分析:6种状态(3种旋转方式*顺逆方向,其他对称的!),首先先打个表,然后很愉快的DFS.自己写的时候费劲脑汁,代码很长,还TLE了... ...

  7. 2013 ACM区域赛长沙 K Pocket Cube hdu 4801

    题意:给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内.最多能翻出几面相同的. 直接打表模拟每种翻转情况 #include<cstdio> #in ...

  8. Hdu-5983 2016ACM/ICPC亚洲区青岛站 B.Pocket Cube 模拟

    题面 题意:给你一个2*2的魔方,给你每个面每个小块的颜色,一共24个,然后问你能否在一步之内还原. 题解:手动在纸上画,推出每种变化对应的置换,显然,一共有6种,而且可以当成3种,(具体哪3种,就是 ...

  9. LA 6621 /ZOJ 3736 Pocket Cube 打表+暴力

    这道题是长沙区域赛的一道简单题,当时题目在ZOJ重现的时候就做了一次,但是做的好复杂,用的BFS暴力,而且还没打表,最后还是莫名其妙的爆栈错误,所以就一直没弄出来,昨天做到大白书上例题05年东京区域赛 ...

随机推荐

  1. css属性所对应js属性

    document.getElementById("xx").style.xxx中的所有属性是什么,css对应js: 盒子标签和属性对照 CSS语法(不区分大小写) JavaScri ...

  2. Shell的for和select

    环境准备: [root@nodchen-db01-test day07]# mkdir -p /server/scripts/day07/test/{test.txt,oldboy.txt,oldgi ...

  3. Linux常用的一些基础命令

    删除 rm -rvf * -f:强制删除文件或文件夹 -r:递归的删除文件或文件夹 -i:删除文件或文件夹前需要确认 -v:详细显示进行步骤 查看 ls ll        ls -l cat mor ...

  4. vlc的应用之二:vlc的ActiveX及cab

    请移步https://higoge.github.io/,所有下载资料在那个博客都能找到.谢谢. http://jeremiah.blog.51cto.com/ 2009-05-14补充:8. Act ...

  5. javascript 中的函数声明和函数表达式区别

    函数声明格式: function add(a, b) { alert(a+b); } 函数表达式格式: var add = function (a, b) { alert(a+b); } 解析器在向环 ...

  6. Web 使用反射获得一个对象的所有get方法

    问题描述: 由于想知道request中包含哪些getter方法,就想通过反射进行遍历,然后输出,结果异常,异常信息: 问题代码: try { outGetter(request); } catch ( ...

  7. openstack 基镜像与差异镜像的整合

  8. 练手THINKPHP5过程和bootstrap3.3.7

    1 在GIT上下载了最新版的源码,同时安装composer 用composer更新 git地址https://github.com/top-think/think 2 搭建本地开发环境,开启url重写 ...

  9. OpenACC 书上的范例代码(Jacobi 迭代),part 2

    ▶ 使用Jacobi 迭代求泊松方程的数值解 ● 首次使用 OpenACC 进行加速,使用动态数组,去掉了误差控制 #include <stdio.h> #include <stdl ...

  10. CUDA C Programming Guide 在线教程学习笔记 Part 8

    ▶ 线程束表决函数(Warp Vote Functions) ● 用于同一线程束内各线程通信和计算规约指标. // device_functions.h,cc < 9.0 __DEVICE_FU ...