hdu 1010 Tempter of the Bone
来源:互联网 发布:柯桥司法拍卖淘宝网 编辑:程序博客网 时间:2024/06/03 20:04
链接:点击打开链接
迷宫搜索,dfs,需要奇偶剪枝,还有注意是刚好在t时刻离开迷宫,我就是因为在t时刻内离开就行而WA数次,改错想死的心都有啦。。
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int n,m,t,x1,y1,x2,y2,ans,x3;char a[10][10];int d[4][2]={0,-1,-1,0,1,0,0,1};void bfs(int x1,int y1,int t){int i,j;if(ans==1) return;if(x1==x2&&y1==y2&&t==0) ans=1;if(t<abs(x1-x2)+abs(y1-y2)||(t-abs(x1-x2)+abs(y1-y2))%2)return;if(x1<1||x1>n||y1<1||y1>m) return; for(i=0;i<4;i++){if(a[x1+d[i][0]][y1+d[i][1]]!='X'){ a[x1+d[i][0]][y1+d[i][1]]='X'; bfs(x1+d[i][0],y1+d[i][1],t-1); a[x1+d[i][0]][y1+d[i][1]]='.';}}return;}int main(){int i,j,sum;while(~scanf("%d %d %d",&n,&m,&t)){if(n==0&&m==0&&t==0)break;getchar(); sum=0;for(i=1;i<=n;i++){ for(j=1;j<=m;j++){scanf("%c",&a[i][j]);if(a[i][j]=='S')x1=i,y1=j;if(a[i][j]=='D')x2=i,y2=j;}getchar();}ans=0;a[x1][y1]='X';bfs(x1,y1,t);if(ans==1)printf("YES\n");elseprintf("NO\n");}return 0;}
- HDU 1010 Tempter of the Bone
- 迷宫 hdu 1010 Tempter of the Bone
- HDU 1010-Tempter of the Bone
- hdu 1010 Tempter of the Bone
- HDU 1010 Tempter of the Bone
- HDU 1010 Tempter of the Bone
- hdu 1010 Tempter of the Bone(深搜)
- HDU 1010 Tempter of the Bone
- HDU 1010 Tempter of the Bone
- HDU 1010 Tempter of the Bone
- hdu 1010 Tempter of the Bone
- HDU-1010-Tempter of the Bone
- hdu 1010 Tempter of the Bone
- HDU 1010-Tempter of the Bone
- HDU 1010 Tempter of the Bone (DFS)
- hdu 1010 Tempter of the Bone
- HDU 1010 - Tempter of the Bone
- hdu 1010 Tempter of the Bone
- 利用win7计划任务本地执行php脚本
- 使用尺寸(dimen)资源
- [Object C]object c中完成将xml转换为json
- svn常用命令介绍[ Ubuntu ]
- Java中的异常处理机制的简单原理和应用
- hdu 1010 Tempter of the Bone
- android- 开源 可拖拽listview ,支持多种模式操作
- 基于滑动窗口的文件发送python
- QT 相关资源
- 如何在CSDN博客添加友情链接 .
- 字符串转换成整数,字符串匹配问题
- DevExpress winform 更换主题
- 查看进程占用的内存大小
- OSGi开发环境建立和Hello World