Tempter of the Bone(HDU 深搜)
来源:互联网 发布:mac 输入法 emoji表情 编辑:程序博客网 时间:2024/04/30 06:46
题目链接
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <string>#include <cmath>#include <queue>using namespace std;int n, m, t;int flag;int sx, sy, dx, dy;char maze[8][8];int vis[8][8];int mv[4][2] = {{0, 1},{1, 0},{-1, 0}, {0, -1}};void dfs(int x, int y, int time){ if(x == dx && y == dy) { if(time == t) flag = 1; } else { if(flag == 1) return; int i; for(i = 0; i < 4; i++) { int tx = x + mv[i][0]; int ty = y + mv[i][1]; if(tx >= 0 && tx < n && ty >= 0 && ty < m && !vis[tx][ty] && (maze[tx][ty] == '.' || maze[tx][ty] == 'D')) { vis[tx][ty] = 1; dfs(tx, ty, time+1); vis[tx][ty] = 0; } } }}int main(){ int i, j; while(cin >> n >> m >> t) { if(!n && !m && !t) break; flag = 0; for(i = 0; i < n; i++) { cin >> maze[i]; for(j = 0; j < m; j++) { if(maze[i][j] == 'S') { sx = i; sy = j; } if(maze[i][j] == 'D') { dx = i; dy = j; } } } memset(vis, 0, sizeof(vis)); vis[sx][sy] = 1; dfs(sx, sy, 0); if(flag == 1) cout << "YES" << endl; else cout << "NO" << endl; } return 0;}
0 0
- Tempter of the Bone(HDU 深搜)
- hdu 1010 Tempter of the Bone(深搜)
- HDU 1010 Tempter of the Bone(深搜)
- hdu Tempter of the Bone(DFS)
- hdu 1010 Tempter of the Bone (深搜+剪枝)
- HDU 1010 Tempter of the Bone(深搜)
- [hdu]Tempter of the Bone
- HDU Tempter of the Bone
- Tempter of the Bone HDU
- Tempter of the Bone HDU
- Tempter of the Bone HDU
- Tempter of the Bone HDU
- HDU1010(Tempter of the Bone)深搜
- Tempter of the Bone(深搜,回溯)
- hdu1010 Tempter of the Bone (深搜)
- Tempter of the Bone (深搜+剪枝)
- zoj 2110(hdu 1010)Tempter of the Bone(深搜)
- HDU OJ 1010 Tempter of the Bone【深搜】
- 机器学习与人工智能学习资源导引(转自刘未鹏)
- linux shell中的管道执行(作业控制有关的shell)
- java学习个人笔记---java内存管理之Java对象的引用方式
- hdu 2544 最短路 spfa
- 华为OJ(按字节截取字符串)
- Tempter of the Bone(HDU 深搜)
- UIControl
- 使用DBCP进行数据源配置
- 使用Genymotion调试出现错误INSTALL_FAILED_CPU_ABI_INCOMPATI
- UNIX文件mode_t详解
- oracle学习笔记——sql脚本范例
- SpringMVC文件下载与上传
- 模运算的规则
- leetCode 117.Populating Next Right Pointers in Each Node II (为节点添加右指针) 解题思路和方法