搜索,没什么好说的。要注意读入。

Code:
 #include<cstdio>
#include<cstdlib>
using namespace std;
const int num[][]=
{{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,}};
int map[][][][],vish[][],visl[][],visn[][],chess[][],h=,l=;
char s[];
void Read()
{
for(int k=;k<=;k++)
{
for(int j=;j<=;j++)
{
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h][l][h][l-]= ( s[]=='>' ? - : );
scanf("%s",s);
map[h][l+][h][l]= ( s[]=='<' ? : - );
l+=;
}
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h+][i][h][i]= ( s[]=='v' ? - : );
}
h++;l=;
}
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h][l][h][l-]= ( s[]=='>' ? - : );
scanf("%s",s);
map[h][l+][h][l]= ( s[]=='<' ? : - );
l+=;
}
h++;l=;
}
}
void print()
{
for(int i=;i<=;i++)
{
for(int j=;j<;j++)
printf("%d ",chess[i][j]);
printf("%d\n",chess[i][]);
}
}
bool check(const int &X,const int &Y,const int &Val)
{
if(map[X][Y][X][Y-]==)
if(Val<=chess[X][Y-])return false;
if(map[X][Y][X][Y-]==-)
if(Val>=chess[X][Y-])return false;
if(map[X][Y][X-][Y]==)
if(Val<=chess[X-][Y])return false;
if(map[X][Y][X-][Y]==-)
if(Val>=chess[X-][Y])return false;
return true;
}
void dfs(int x,int y)
{
if(x==)
{
print();
exit();
}
for(int i=;i<=;i++)
if(!vish[x][i]&&!visl[y][i]&&!visn[num[x][y]][i])
if(check(x,y,i))
{
chess[x][y]=i;
vish[x][i]=visl[y][i]=visn[num[x][y]][i]=true;
if(y==)
dfs(x+,);
else
dfs(x,y+);
vish[x][i]=visl[y][i]=visn[num[x][y]][i]=false;
}
}
int main()
{
Read();
dfs(,);
return ;
}

最新文章

  1. CSS3——transform学习
  2. 在Ubuntu上安装网易云音乐
  3. PHP获取具有相同name的多个input表单信息
  4. 通俗易懂的ListView讲解(Adapter、图、实例)
  5. 【JAVA、C++】LeetCode 017 Letter Combinations of a Phone Number
  6. webkit浏览器渲染影响因素分析
  7. ASP.NET MVC 开源项目学习之ProDinner (三)
  8. vs中使用过的扩展和好的nuget库
  9. [转载]jQuery.extend 函数详解
  10. Javascript/Jquery 中each() 和forEach()的区别
  11. Django -- static
  12. 开源分享,使用Servlet实现360商城
  13. .NetCore外国一些高质量博客分享
  14. 使用mkbootfs制作ramdisk根文件系统
  15. 对世界首款“人工智能”ERP系统HUE的初步了解 - AI ERP - WAP - 万革始
  16. Hadoop2.7.6_02_HDFS常用操作
  17. 侧滑返回导航栏以及TabBar隐藏和显示带来的坑
  18. rails gem更换ruby-china源
  19. HTTP Status 500 PWC6188 jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
  20. Objective-C中的hasPrefix

热门文章

  1. 【bug】vue-cli 3.0报错的解决办法
  2. Eureka Server的高可用
  3. Java 中的静态内部类
  4. perl HTML::LinkExtor模块(1)
  5. Linux内核基础--事件通知链(notifier chain)【转】
  6. 1002: 当不成勇者的Water只好去下棋了---课程作业---图的填色
  7. Lambda 表达式 in java 8
  8. spring mvc注解文件上传下载
  9. gridcontrol的列头右键菜单问题
  10. hdu 5023