Pocket Cube
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
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.
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 |
+ - + - +
纯模拟= =,训练的时候脑抽没写出来
#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的更多相关文章
- 2013区域赛长沙赛区现场赛 K - Pocket Cube
K - Pocket Cube Time Limit:10000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- HDU 5292 Pocket Cube 结论题
Pocket Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5292 Description Pocket Cube is the 2×2× ...
- 【】【】Pocket Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s) ...
- 【HDOJ】4801 Pocket Cube 的几种解法和优化
1. 题目描述给定一个$2 \times 2 \times 2$的魔方,当某个面上的4个小块颜色均相同时,称这个面为complete.求对这个魔方进行$n \in [1,7]$次旋转(沿某个面顺时针或 ...
- HDU 4801 Pocket Cube
题目链接 去年现场,虎哥1Y的,现在刷刷题,找找状态... 一共6种转法,把3个面放到顶部,左旋和右旋,感觉写的还不错....都写成常数了. #include <stdio.h> #inc ...
- 模拟 ZOJ 3736 Pocket Cube
题目传送门 题意:魔方最多旋转n次,问最多能使多少面颜色相同 分析:6种状态(3种旋转方式*顺逆方向,其他对称的!),首先先打个表,然后很愉快的DFS.自己写的时候费劲脑汁,代码很长,还TLE了... ...
- 2013 ACM区域赛长沙 K Pocket Cube hdu 4801
题意:给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内.最多能翻出几面相同的. 直接打表模拟每种翻转情况 #include<cstdio> #in ...
- Hdu-5983 2016ACM/ICPC亚洲区青岛站 B.Pocket Cube 模拟
题面 题意:给你一个2*2的魔方,给你每个面每个小块的颜色,一共24个,然后问你能否在一步之内还原. 题解:手动在纸上画,推出每种变化对应的置换,显然,一共有6种,而且可以当成3种,(具体哪3种,就是 ...
- LA 6621 /ZOJ 3736 Pocket Cube 打表+暴力
这道题是长沙区域赛的一道简单题,当时题目在ZOJ重现的时候就做了一次,但是做的好复杂,用的BFS暴力,而且还没打表,最后还是莫名其妙的爆栈错误,所以就一直没弄出来,昨天做到大白书上例题05年东京区域赛 ...
随机推荐
- 在ie6下的png图片的兼容问题
png图片在ie6下是这样的: 正确样式: 这样解决: html代码: <body> <div class="gys"></div> </ ...
- Linux Performance Analysis and Tools(Linux性能分析和工具)
首先来看一张图: 上面这张神一样的图出自国外一个Lead Performance Engineer(Brendan Gregg)的一次分享,几乎涵盖了一个系统的方方面面,任何人,如果没有完善的计算系统 ...
- Noip2011Mayan游戏
题目描述 Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个 7 行5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他方块之上.游戏通关是指在规定 ...
- 如何决定Web应用的线程池大小
线程池(Thread Pool)在Web应用中线程池的大小决定了在任何一个时间点应用可以处理请求的并发数.如果一个系统收到的请求数超过了线程池的大小,那么超出的请求要么进入等待队列要么被拒绝.请注意, ...
- SpringJdbc之queryForXXX大全解读
一.查询单个字段 Object queryForObject(String sql, Object[] args, Class requiredType) 其中Class requiredTy ...
- Python之——遇到的小知识点总结
学习过程中,难免会遇到一些冷门的小知识点,熟悉这些小知识可以在工作中达到事半功倍的效果,尽力消除自己的知识盲区.总之当时的自己花了不少功夫去解决这些问题,因此觉得有必要单独记录下来,以后也许会再遇到, ...
- django-插件django REST framework,返回序列化的数据
官网: http://www.django-rest-framework.org 1.安装 pip install djangorestframework 2.在setting.py中注册app 中添 ...
- 0_Simple__simpleTexture + 0_Simple__simpleTextureDrv
使用纹理引用来旋转图片,并在使用了静态编译和运行时编译两种环境. ▶ 源代码:静态编译 #include <stdio.h> #include <windows.h> #inc ...
- ucenter 认证登录
1==>new RegisterBase($email, $password, $repassword, $client_id, $client_secret, $is_from) 1.1 ...
- 序列化和反序列化(json 和pickle)dumps 为序列化, json为反序列化
json 可以在不同语言中进行使用 下面先介绍一下json的适用方法 import json, pickle t1 = { 'name':'alex', ', ' } t1 = json.dumps( ...