HDOJ 1010
来源:互联网 发布:类似omnifocus的软件 编辑:程序博客网 时间:2024/06/07 03:46
HDOJ 1010
#include<iostream>#include<algorithm>#include<cstdio>#include<cmath>#include<iomanip>#include<cfloat>using namespace std;bool flag;char a[10][10];int n, m, t, di, dj;int c[4][2] = { { 1,0 },{ 0,1 },{ 0,-1 },{ -1,0 } };void keng(int x,int y,int s) { int i; if (flag) { return; } if (a[x][y] == 'X') { return; } if (x == di&&y == dj&&s == t) { flag = 1; return; } if (x < 0 || x >= n || y < 0 || y >= m) { return; } for (i = 0;i < 4;i++) { a[x][y] = 'X'; keng(x + c[i][0], y + c[i][1], s + 1); if (flag) return; a[x][y] = '.'; }}int main(){ while ((scanf("%d%d%d",&n,&m,&t))&& (n || m || t)) { getchar(); int si, sj, k = 0; flag = 0; for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { scanf("%c", &a[i][j]); if (a[i][j] == 'S') { si = i; sj = j; } else if (a[i][j] == 'X') { k++; } else if (a[i][j] == 'D') { di = i; dj = j; } } getchar(); } if (n*m - k < t) { cout << "NO" << endl; } else if ((si + sj + di + dj + t) % 2 == 1) { cout << "NO" << endl; } else { keng(si, sj, 0); if (flag) cout << "YES" << endl; else cout << "NO" << endl; } } return 0;}
0 0
- HDOJ 1010
- HDOJ 1010
- HDOJ 1010
- HDOJ--1010
- hdoj 1010 基本搜索
- HDOJ 1010 解题
- hdoj 1010 <dfs剪枝>
- HDOJ-----1010DFS
- hdoj 1010 DFS +减枝
- HDOJ
- hdoj
- hdoj
- HDOJ
- HDOJ 1010 迷宫搜索 剪枝
- HDOJ(1010)DFS+剪枝
- HDOJ 1010 DFS 170MS
- hdoj 1010 Tempter of the Bone
- HDOJ 1010 Tempter of the Bone
- 聊聊分布式事务
- hdu 3746 Cyclic Nacklace(kmp)
- Android工程结构
- javaproject更新后仍然报找不到类或属性
- UVA 10891 - Game of Sum*
- HDOJ 1010
- Android--SlidingMenu 使用详解
- repo使用简介
- The library 'sqlite-native-driver.jar' contains native libraries that will not run on the device.
- nginx虚拟目录配置(php-fpm+fastcgi)
- 【Java并发编程实战】—–“J.U.C”:锁,lock
- 【基础练习】【区间DP】codevs3657 括号序列题解
- ZooKeeper典型应用场景
- WebView注入Java对象注意事项 [INFO:CONSOLE(475)] "Uncaught TypeError: Object [object Object] has no method