ZOJ 3736 Pocket Cube(暴力,魔方)
来源:互联网 发布:网络运营部职责 编辑:程序博客网 时间:2024/04/28 02:42
魔方的题,暴力睡过。1930ms,差点久挂了。
#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <cmath>#include <cstring>#include <iostream>#include <queue>#include <map>#include <stack>#include <string>#include <algorithm>#include <vector>#include <list>#include <deque>#define LL long long#define DB double#define SI(a) scanf("%d",&a)#define SD(a) scanf("%lf",&a)#define SS(a) scanf("%s",a)#define PF printf#define MM(a,b) memset(a,b,sizeof(a))#define REP(i,a,b) for(int i=a;i<b;i++) #define REPD(i,a,b) for(int i=a;i>b;i--)#define INF 0x3f3f3f3f#define EPS 1e-8#define bug puts("bug")using namespace std;#define N 25int tun1[3][4] = { 2,3,1,0, 7,6,12,13, 8,9,15,14};int tun2[3][8] = { 4,5,6,7,8,9,23,22, 3,2,5,11,16,17,14,8, 23,21,19,17,13,7,3,1,};struct nod{ int re[N]; void in() { REP(i,0,24) SI(re[i]); } int cc(int a,int b,int c,int d) { if(re[a]==re[b]&&re[b]==re[c]&&re[c]==re[d]) return 1; return 0; } int get() { int ret =0; if(cc(0,1,2,3)) ret++; if(cc(4,5,11,10)) ret++; if(cc(6,7,12,13)) ret++; if(cc(8,9,14,15)) ret++; if(cc(16,17,18,19)) ret++; if(cc(20,21,22,23)) ret++; return ret; } void oor(int k) { int t; t = re[tun1[k][3]]; REPD(i,3,0) re[tun1[k][i]] = re[tun1[k][i-1]]; re[tun1[k][0]] = t; t = re[tun2[k][7]]; REPD(i,7,0) re[tun2[k][i]] = re[tun2[k][i-1]]; re[tun2[k][0]] = t; t = re[tun2[k][7]]; REPD(i,7,0) re[tun2[k][i]] = re[tun2[k][i-1]]; re[tun2[k][0]] = t; } void l1(int k) { oor(k); } void l2(int k) { oor(k);oor(k); oor(k); }} ini,tmp;int pow(int k) { int ret = 1; while(k--) { ret *= 6; } return ret;}int ans = 0;void solve(int c,int k) { for(int i=0;i<c;i++) { int t = k%6;k/=6; if(t<3) tmp.l1(t); else tmp.l2(t-3); } ans = max(ans,tmp.get());}int main(){ #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int n; while(~SI(n)) { ini.in(); ans =0; for(int i=0;i<=n;i++) { int k = pow(i); for(int j=0;j<k;j++){ tmp = ini; solve(i,j); } } PF("%d\n",ans); } return 0;}
- ZOJ 3736 Pocket Cube(暴力,魔方)
- ZOJ 3736 Pocket Cube
- ZOJ 3736 Pocket Cube
- [dfs] zoj 3736 Pocket Cube
- hdu 4801 Pocket Cube(暴力)
- UVALive 6621 Pocket Cube(暴力)
- HDU 5983 Pocket Cube (暴力)
- ZOJ 3736 Pocket Cube 脑补+BFS
- ZOJ 3736——Pocket Cube
- HDU 5983-Pocket Cube(一步还原二阶魔方)
- zoj 3726 Pocket Cube(搜索)
- HDU 4801 Pocket Cube(暴力模拟 dfs)
- zoj 3736 Pocket Cube(2013亚洲区域赛 长沙站 K)
- ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索
- ZOJ 2477 Magic Cube 三阶魔方还原(IDA*)
- HDU 4801 Pocket Cube(模拟题——转魔方)
- hdu 5983Pocket Cube(16青岛现场赛)一步能否还原二层魔方?
- hdu 4801 Pocket Cube 四面魔方,模拟+搜索
- uiscrollView 原理详解
- [Android开发实战]Android添加快捷方式到桌面的两种方式
- [Ant][StartWithAnt] 第五章 条件判断Contidion 3.字符串匹配
- Hive Cli
- VS2010 Cocos2d-x 2.2创建模板
- ZOJ 3736 Pocket Cube(暴力,魔方)
- 手动给Qt creator添加工具链和编译器
- JAVA Swing异或图形模式
- C++ 数据转换总结
- 百度ueditor not import language file
- LeetCode 3Sum 三个数和为零的集合 C++完整程序
- C++Primer笔记
- WPF之检测鼠标位置
- java学习06-静态static 与JVM内存分配