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. python 使用selenium和requests爬取页面数据

    目的:获取某网站某用户下市场大于1000秒的视频信息 1.本想通过接口获得结果,但是使用post发送信息到接口,提示服务端错误. 2.通过requests获取页面结果,使用html解析工具,发现麻烦而 ...

  2. Oracle中分页查询和联表查询

    1.使用ROWNUM伪列查询 1.1.查询十条数据(rownum<=n) SELECT ROWNUM,A.* FROM v_sjjx_unit_info A WHERE ROWNUM<=1 ...

  3. async await promise 执行时序

    先用一个例子来说明async await promise的执行顺序 console.log('start'); async function test(){ console.log('111'); a ...

  4. VFS文件系统结构分析

    VFS是Linux非常核心的一个概念,linux下的大部分操作都要用到VFS的相关功能.这里从使用者的角度,对VFS进行了简单说明.使用者不但需要知道Linux下有哪些文件操作的函数,还需要对VFS的 ...

  5. 关于Node和Deno

    Node和Deno的作者Ryan Dahl开Deno并不是“just for fun”, 也不是为了取代Node, 他有着更加远大的目标. 记住以下要点: 1. Deno目前只是一个Demo或者说是原 ...

  6. JavaScript字符串练习

    题目: 预备代码: // 自定义输出 var log = function () { console.log.apply(this, arguments); }; // ====== // 测试 // ...

  7. 解决Visual Studio “无法导入以下密钥文件”的错误

    错误1无法导入以下密钥文件: Common.pfx.该密钥文件可能受密码保护.若要更正此问题,请尝试再次导入证书,或手动将证书安装到具有以下密钥容器名称的强名称 CSP: VS_KEY_ 1110Co ...

  8. checkbox的美化(转)

    http://www.w3cfuns.com/blog-5422889-5398674.html <!DOCTYPE html> <html> <head> < ...

  9. 3.mybatis实战教程(mybatis in action)之三:实现数据的增删改查

    转自:https://blog.csdn.net/tangruyi1992/article/details/52583910 前面已经讲到用接口的方式编程.这种方式,要注意的一个地方就是.在User. ...

  10. 2.mybatis实战教程(mybatis in action)之二:以接口的方式编程

    转自:http://www.yihaomen.com/article/java/304.htm 前面一章,已经搭建好了eclipse,mybatis,mysql的环境,并且实现了一个简单的查询. 请注 ...