搜索题,

每个状态能扩展出12种状态,最多进行5次旋转12^5

要用到iddfs,或者我看到网上其他人用的ida*

我也是参考了别人的代码,而且这个题vj上有点问题,我看数据看了半天,愣是没看明白第二个数据咋回事,后来才知道是vj显示的有问题

#include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
using namespace std;
#define ll long long
#define se second
#define fi first
#define oo 0x3fffffff
/*
4
0 1 2 3
5 1 2 3
// 4 5 6
// 7 8 9
//10 11 12 13 14 15 16 17 18 19 20 21
//22 23 24 25 26 27 28 29 30 31 32 33
//34 35 36 37 38 39 40 41 42 43 44 45
// 46 47 48
// 49 50 51
// 52 53 54
*/
int cent[] = {, , , , , };
int face[][] = {
{,,,,,,,,},
{,,,,,,,,},
{,,,,,,,,},
{,,,,,,,,},
{,,,,,,,,},
{,,,,,,,,}
};
int change[][] = {
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,}
};
char s[];
int a[],b[];
int maxdepth;
int l = ;
bool dfs(int dep);
bool judge();
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
l = ;
for(int i = ;i <= ; ++i)
scanf(" %c",s+i);
//for(int i = 1; i <= 54; ++i)
// printf("%c",s[i]);
for(maxdepth = ;maxdepth <= ; ++maxdepth)
{
if(dfs())
{
if(l == )
{
printf("0\n");break;
}
printf("%d\n", l);
for(int i = ; i < l-; ++i)
{
printf("%d %d ",a[i],b[i]);
}
printf("%d %d\n",a[l-],b[l-]);
break;
}
}
if(maxdepth == )
printf("-1\n");
}
}
bool judge()
{
for(int i = ; i < ; ++i)
{
for(int j = ; j < ; ++j)
{
if(s[face[i][j]] != s[cent[i]])
return false;
}
}
return true;
}
bool dfs(int dep)
{
if(judge())
{
l = dep;
return true;
}
if(dep >= maxdepth)
return false;
char tmp[];
memcpy(tmp,s,sizeof s);
for(int i = ; i < ; ++i)
{
for(int j = ; j < ; ++j)
{
s[change[i][j]] = tmp[change[i^][j]];
}
/*if(dep == 0)
{
for(int i = 0; i < 6; ++i)
for(int j = 0; j < 9; ++j)
printf("%c",s[face[i][j]]);
cout << " " << (i&1) << endl;
cout << endl;
}*/
a[dep] = i/;
b[dep] = i&?-:;
if(dfs(dep+)) return true;
memcpy(s,tmp,sizeof tmp);
}
return false;
}

最新文章

  1. Atitit 硬件&#160;软件&#160;的开源工作&#160;差异对比
  2. 洛谷10月月赛Round.3
  3. Windows Phone 开发环境的搭建
  4. HTML5文件API
  5. Model-View-Controller - 杂谈
  6. Linux系统文件权限&amp;目录权限
  7. MEF 编程指南(六):导出和元数据
  8. AFN演示
  9. Android 关于屏幕适配
  10. Linux下,命令 wget 的使用
  11. 蛋疼的Apple IOS Push通知协议
  12. LeetCode OJ 292.Nim Gam148. Sort List
  13. Collector for ArcGIS的使用体验
  14. mysql笔记一——安装和设置root密码
  15. sqlserver isnull判断
  16. C# Ioc ASP.NET MVC Dependency Injection
  17. Zookeeper的功能以及工作原理 (转自:http://www.cnblogs.com/felixzh/p/5869212.html)
  18. 最大的k个数问题
  19. CoUninitialize引发的一个错误
  20. Linux 进程后台运行的几种方式 screen

热门文章

  1. Python全栈开发记录_第二篇(文件操作及三级菜单栏增删改查)
  2. log4j配置后行号乱码显示为?问号
  3. JavaScript学习-3——数组、函数、递归
  4. python练习题_02
  5. [译]与TensorFlow的第一次接触(三)之聚类
  6. GDI+_SavePic
  7. Spring中@相关注解的意义
  8. flume知识点总结
  9. gridView 删除一行后自动定位到指定行
  10. Html利用CSS布局技巧