(HDU1010)Tempter of the Bone
来源:互联网 发布:四知先生翻译 编辑:程序博客网 时间:2024/06/06 01:00
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1010
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<cstdlib>#include<sstream>#include<set>#include<algorithm>#include<queue>#include<stack>#include<vector>#include<ctime>#include<fstream>#include<iomanip>using namespace std;#define M 105int n,m,t,si,sj,ei,ej,c,wall;char ma[M][M];int dir[4][2]={{0, 1}, {0, -1}, {1, 0}, {-1, 0}};void DFS(int x, int y, int time){ if (x<=0||x>n||y<=0||y>m) return; if (c) return; if (x == ei && y == ej && time == t) { if(time == t) c = 1; return; } int temp = (t - time) - abs(x - ei) - abs(y - ej); if(temp<0 || temp & 1) return; for (int i=0;i<4;i++) { int x1=x+dir[i][0]; int y1=y+dir[i][1]; if (ma[x1][y1]!='X') { ma[x1][y1]='X'; DFS(x1, y1,time+1); ma[x1][y1]='.'; } } return;}int main(){ while (cin>>n>>m>>t) { if(n==0&&m==0&&t==0) break; wall = 0; for (int i = 1; i<=n; i++) { for (int j = 1; j<=m; j++) { cin>>ma[i][j]; if (ma[i][j] == 'S') { si = i; sj = j; } if (ma[i][j] == 'D') { ei = i; ej = j; } if (ma[i][j] == 'X') wall ++; } } c = 0; ma[si][sj] = 'X'; if (n * m - wall <= t) { cout<<"NO"<<endl; continue; } DFS(si, sj, 0); if (c) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0;}
0 0
- HDU1010 Tempter of the Bone
- Tempter of the Bone hdu1010
- (hdu1010)Tempter of the Bone
- hdu1010 Tempter of the Bone
- HDU1010 Tempter of the Bone
- HDU1010 Tempter of the Bone
- HDU1010:Tempter of the Bone
- HDU1010 Tempter of the Bone
- HDU1010 Tempter of the Bone
- hdu1010(Tempter of the Bone)
- hdu1010 Tempter of the Bone
- HDU1010 Tempter of the Bone
- hdu1010 Tempter of the Bone
- hdu1010 Tempter of the Bone
- hdu1010 Tempter of the Bone
- hdu1010---Tempter of the Bone
- HDU1010---Tempter of the Bone
- hdu1010 Tempter of the Bone
- Genymotion终于复活了
- 51nod oj 1191 消灭兔子 【vector 二分+贪心】
- Spark 中的二次排序Java实现
- 建模
- 第3周项目2-建设“顺序表”算法库
- (HDU1010)Tempter of the Bone
- AsyncTask简单使用(下载图片)
- HDOJ1106-排序
- Java自定义生成与解析(Dom4J)XML文件
- 脚本开发
- 凯撒密码
- css3中属性选择器的使用
- Leetcode 刷题助手-legit-python实现
- PATH下发