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年东京区域赛 ...
随机推荐
- C# winfrom ComboBox 调整下拉菜单的高度
1.设置属性 // 1.属性设置 DrawMode ->OwnerDrawVariable this.cboBoxPostID.DrawMode = System.Windows.Forms.D ...
- [转]Excel.dll 导出Excel控制
Excel.dll 导出Excel控制 2010-06-12 11:26 2932人阅读 评论(2) 收藏 举报 excelmicrosoftstring产品服务器google 最近做了个导出Exce ...
- [转]C#鼠标拖动任意控件
C#鼠标拖动任意控件(winform) 分类: c#2011-08-15 22:51 178人阅读 评论(0) 收藏 举报 winformc#userwindowsobjectapi using Sy ...
- android官方文档翻译(不断更新中。。。)
最近在自学android,抽空把官方文档的guide跟training差不多看了一遍,又对比了一些书籍,感觉还是官方文档讲得比较好,所以自己计划把官方文档翻译一下,方便自己的知识巩固以及复习查找,由于 ...
- 【RL前沿】深度强化学习的最新进展 by 2017.12.12
作者:Volodymyr Mnih Google DeepMind科学家. 在Geoffrey Hinton的指导下完成了多伦多大学的机器学习博士学位. 在此之前,在Csab Szepesvari的指 ...
- PyQt5系列教程(七)控件
软硬件环境 Windows 10 Python 3.4.2 PyQt 5.5.1 PyCharm 5.0.4 前言 控件是PyQt应用程序的基石.PyQt5自带很多不同的控件,包括像button.ch ...
- 20165233 2017-2018-2 《Java程序设计》课程总结
20165233 2017-2018-2 课程总结 每周作业链接汇总 第0周 预备作业1 我期望的师生关系 预备作业2 学习基础和C语言基础调查 预备作业3 Linux安装及学习 第1周 第1周作业 ...
- HTML5 学习之地理定位
html5 获取坐标: <!DOCTYPE HTML> <html> <head> <title>test1.html</title> &l ...
- 《GPU高性能编程CUDA实战》第九章 原子性
▶ 本章介绍了原子操作,给出了基于原子操作的直方图计算的例子. ● 章节代码 #include <stdio.h> #include "cuda_runtime.h" ...
- 23. oralce11g导出dmp然后导入Oracle10g
解决方法: 一.在11g服务器上,使用expdp命令备份数据 EXPDP USERID='fjgs/fjgs@orcl' schemas=fjgs directory=DATA_PUMP_DIR du ...