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年东京区域赛 ...
随机推荐
- LDA-MySql
http://blog.csdn.net/white_smile/article/details/19565701
- python simplejson and json 使用及区别
''' import simplejson as json #几个主要函数:dump.dumps.load.loads,带s跟不带s的区别: 带s的是对 字符串的处理,而不带 s的是对文件对像的处理. ...
- iframe引入百度地图显示企业位置
步骤一:打开下面这个地址:http://api.map.baidu.com/lbsapi/creatmap/index.html 步骤二:定位中心点 在打开的页面左侧,输入企业的详细地 ...
- linux上很方便的上传下载文件工具rz和sz使用介绍
简单说就是,可以很方便地用这两个sz/rz工具,实现Linux下和Windows之间的文件传输(发送和接收),速度大概为10KB/s,适合中小文件.rz/sz 通过Zmodem协议传输数据 一般来 ...
- python之路之函数02
一 函数的参数: 我们把函数的参数分为形式参数和实际参数,简称形参和实参. 形参:在定义函数时,函数名括号内定义的参数. 实参:在调用函数时,函数名括号内需要用户传入的值. 注意: 实参值(相当于变 ...
- 线程池,queue模块增加用法
1 同一个进程内的队列(多线程) import queue queue.Queue() 先进先出 queue.LifoQueue() 后进先出 queue.PriorityQueue() 优先级队列 ...
- python入门第0篇 Windows下python的安装及pip安装和使用
知识内容: 1. python2和python3安装 2. pip安装及pip命令使用 注:安装python3就可以了,python2除非项目开发需要否则不用安装,目前学习python就使用pytho ...
- 2018-2019-2 《网络对抗技术》Exp5 MSF基础应用 Week7-8 20165233
Exp5 MSF基础应用 目录 一.基础问题 二.攻击实例 主动攻击 ms08_067_netapi(成功) ms10_061_spoolss(失败) 针对浏览器的攻击 ms14_064_ole_co ...
- 表单:checkbox、radio样式(用图片换掉默认样式)
checkbox.radio样式(用图片换掉默认样式) <!doctype html> <html> <head> <meta charset="u ...
- OpenACC parallel
▶ 使用 kernels 导语并行化 for 循环 ● 同一段代码,使用 kernels,parallel 和 parallel + loop 进行对比 #include <stdio.h> ...