zoj 3736 Pocket Cube(2013亚洲区域赛 长沙站 K)
来源:互联网 发布:js获取div name 编辑:程序博客网 时间:2024/04/28 07:38
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3736
Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes. For a combination of 2 × 2 mini-cubes which sharing a whole cube face, you can twist it 90 degrees in clockwise or counterclockwise direction, this twist operation is called one twist step.
Considering all faces of mini-cubes, there will be totally 24 faces painted in 6 different colors (Indexed from 0), and there will be exactly 4 faces painted in each kind of color. If 4 mini-cubes' faces of same color rely on same large cube face, we can call the large cube face as a completed face.
Now giving you an color arrangement of all 24 faces from a scrambled Pocket Cube, please tell us the maximum possible number of completed faces in no more than N twist steps.
Index of each face is shown as below:
#include <iostream>#include <string.h>#include <stdio.h>using namespace std;void up(int *a){ int tmp=a[6];a[6]=a[7];a[7]=a[13];a[13]=a[12];a[12]=tmp; tmp=a[11];a[11]=a[2];a[2]=a[8];a[8]=a[17];a[17]=tmp; tmp=a[5];a[5]=a[3];a[3]=a[14];a[14]=a[16];a[16]=tmp;}void left(int *a){ int tmp=a[11];a[11]=a[5];a[5]=a[4];a[4]=a[10];a[10]=tmp; tmp=a[0];a[0]=a[20];a[20]=a[16];a[16]=a[6];a[6]=tmp; tmp=a[2];a[2]=a[22];a[22]=a[18];a[18]=a[12];a[12]=tmp;}void front(int *a){ int tmp=a[0];a[0]=a[2];a[2]=a[3];a[3]=a[1];a[1]=tmp; tmp=a[22];a[22]=a[5];a[5]=a[7];a[7]=a[9];a[9]=tmp; tmp=a[23];a[23]=a[4];a[4]=a[6];a[6]=a[8];a[8]=tmp;}int check(int a,int b,int c,int d){ if(a==b&&a==c&&a==d) return 1; return 0;}int ans;int getnum(int *a){ int num=0; num+=check(a[0],a[1],a[2],a[3]); num+=check(a[4],a[5],a[10],a[11]); num+=check(a[6],a[7],a[12],a[13]); num+=check(a[8],a[9],a[14],a[15]); num+=check(a[16],a[17],a[18],a[19]); num+=check(a[20],a[21],a[22],a[23]); return num;}void (*(func)[3])(int *);void dfs(int *a,int lef){ ans=max(ans,getnum(a)); if(ans==6) return; if(lef==0) return; int b[24]; for(int i=0;i<3;i++) { memcpy(b,a,sizeof(int)*24); func[i](b); dfs(b,lef-1); func[i](b);func[i](b); dfs(b,lef-1); }}int main(){ //freopen("dd.txt","r",stdin); int n; func[0]=front;func[1]=left;func[2]=up; while(scanf("%d",&n)!=EOF) { int a[24]; for(int i=0;i<24;i++) { scanf("%d",&a[i]); } ans=0; dfs(a,n); printf("%d\n",ans); } return 0;}
- zoj 3736 Pocket Cube(2013亚洲区域赛 长沙站 K)
- 2013长沙现场赛 K . Pocket Cube
- 2013 长沙现场赛 K (Pocket Cube)
- 2013亚洲区域赛长沙站 ZOJ 3732 Graph Reconstruction
- zoj 3735 Josephina and RPG (2013 亚洲区域赛 长沙站 J)
- zoj 3728 Collision(2013亚洲区域赛 长沙站 C)
- 2013 亚洲区域赛 长沙站
- zoj 3733 (hdu 4798) Skycity (2013 亚洲区域赛 长沙站 H)
- ZOJ 3736 Pocket Cube
- ZOJ 3736 Pocket Cube
- ZOJ 3736 Pocket Cube(暴力,魔方)
- 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-K ( ZOJ 3829 ) Known Notation
- [dfs] zoj 3736 Pocket Cube
- ZOJ 3822 Domination(DP,亚洲区域赛牡丹江站)
- ZOJ 3736 Pocket Cube 脑补+BFS
- ZOJ 3736——Pocket Cube
- HDU 5983 Pocket Cube ICPC亚洲区青岛站(模拟)
- 2013长沙区域赛——C.Collision(ZOJ 3728)
- 【COCOS2DX-ANDROID-游戏开发之十九】android编译之ctime:66: error: ‘::clock_t’ has not been declared
- 没有文件扩展“.js”的脚本引擎问题解决
- 五险一金用处及投放技巧(工作上的那些事儿)
- solr 使用
- SDL源码阅读笔记(3)渲染模块
- zoj 3736 Pocket Cube(2013亚洲区域赛 长沙站 K)
- android-x86 的安装和设置使用笔记
- Chapter 1 | Arrays and Strings--字符串的翻转与去重
- 暴力求解法-双基回文数
- [PKU1655]Balancing Act
- 设计包含min函数的栈
- TCP与UDP的区别,以及它们各自的定义
- 银河面试总结
- wifi无线网络连接定时器