ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索
来源:互联网 发布:库里三分数据 编辑:程序博客网 时间:2024/05/01 12:28
题意:
给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内..最多能翻出几面相同的...
题解:
开始自己打了个10行表..好难找错..然后发现..其实只要六个就行了..因为左侧正90转和右侧负90转时一样的..
论科学打表..自己手动裁剪一个2*2的魔方..标好号..观察一下就可以了..
Prgoram:
#include <iostream>#include <stdio.h>#include <string.h>#include <cmath>#include <algorithm>using namespace std;int B[6][24]={ {6,1,12,3,5,11,16,7,8,9,4,10,18,13,14,15,20,17,22,19,0,21,2,23}, //ok {20,1,22,3,10,4,0,7,8,9,11,5,2,13,14,15,6,17,12,19,16,21,18,23}, //ok {1,3,0,2,23,22,4,5,6,7,10,11,12,13,14,15,16,17,18,19,20,21,9,8}, //ok {2,0,3,1,6,7,8,9,23,22,10,11,12,13,14,15,16,17,18,19,20,21,5,4}, //ok {0,1,8,14,4,3,7,13,17,9,10,2,6,12,16,15,5,11,18,19,20,21,22,23}, //ok {0,1,11,5,4,16,12,6,2,9,10,17,13,7,3,15,14,8,18,19,20,21,22,23} //ok };int ans;void update(int *h){ int sum=0; if (h[0]==h[1] && h[1]==h[2] && h[2]==h[3]) sum++; if (h[4]==h[5] && h[5]==h[10] && h[10]==h[11]) sum++; if (h[6]==h[7] && h[7]==h[12] && h[12]==h[13]) sum++; if (h[8]==h[9] && h[9]==h[14] && h[14]==h[15]) sum++; if (h[16]==h[17] && h[17]==h[18] && h[18]==h[19]) sum++; if (h[20]==h[21] && h[21]==h[22] && h[22]==h[23]) sum++; ans=max(ans,sum);}void dfs(int N,int *h){ update(h); if (!N) return; int k,i,p[24]; for (k=0;k<6;k++) { for (i=0;i<24;i++) p[i]=h[B[k][i]]; dfs(N-1,p); } return;}int main(){ int N,i,h[24]; while (~scanf("%d",&N)) { for (i=0;i<24;i++) scanf("%d",&h[i]); ans=0; dfs(N,h); printf("%d\n",ans); } return 0;}
- ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索
- zoj 3726 Pocket Cube(搜索)
- ZOJ 3736 Pocket Cube
- ZOJ 3736 Pocket Cube
- hdu 4801 Pocket Cube
- HDU 4801 Pocket Cube
- [dfs] zoj 3736 Pocket Cube
- hdu 4801 Pocket Cube 四面魔方,模拟+搜索
- HDU 4801 Pocket Cube BFS
- HDU 4801 Pocket Cube bfs
- ZOJ 3736 Pocket Cube 脑补+BFS
- ZOJ 3736 Pocket Cube(暴力,魔方)
- ZOJ 3736——Pocket Cube
- hdu 4801 Pocket Cube(暴力)
- hdu 4801 Pocket Cube(dfs+模拟)
- HDU 5292 Pocket Cube
- hdu 5292 Pocket Cube
- hdu 5292 Pocket Cube
- http协议Chunked transfer encoding
- JQuery Datatable Ajax请求两次问题的解决
- swing 颜色、图片边框(MatteBorder)
- Oracle_11g常用SQL语句(高级工程师必备)
- Django 1.5 CBV
- ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索
- Web安全之SQL注入攻击
- 网题“不可表示的数”解答
- 基于visual Studio2013解决C语言竞赛题之0408素数
- vi 显示行号、语法高亮、自动缩进的设置
- 使用脚本设计自动化测试框架的原则
- 移植Linux内核到s3c6410(使用busybox构建initrd ramdisk)
- KMP算法原理与实现(精简)
- 这么年轻就有职业病了