Tempter of the Bone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38029 Accepted Submission(s): 10265
Problem Description
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.
The maze was a rectangle with sizes N by M. There was a door in the maze. At the beginning, the door was closed and it would open at the T-th second for a short period of time (less than 1 second). Therefore the doggie had to arrive at the door on exactly the T-th second. In every second, he could move one block to one of the upper, lower, left and right neighboring blocks. Once he entered a block, the ground of this block would start to sink and disappear in the next second. He could not stay at one block for more than one second, nor could he move into a visited block. Can the poor doggie survive? Please help him.
Input
The input consists of multiple test cases. The first line of each test case contains three integers N, M, and T (1
‘X’: a block of wall, which the doggie cannot enter;
‘S’: the start point of the doggie;
‘D’: the Door; or
‘.’: an empty block.
The input is terminated with three 0’s. This test case is not to be processed.
Output
For each test case, print in one line “YES” if the doggie can survive, or “NO” otherwise.
Sample Input
4 4 5
S.X.
..X.
..XD
….
3 4 5
S.X.
..X.
…D
0 0 0
Sample Output
NO
YES
Author
ZHANG, Zheng
Source
ZJCPC2004
Recommend
JGShining
#include
#include
#include
#include
using namespace std;
const int tx[]={0,0,1,-1};
const int ty[]={1,-1,0,0};
char map[10][10];
int n,m,t,ans;
int dx,dy;
void dfs(int x,int y,int t)
{
int z=abs(x-dx)+abs(y-dy);
if(z>t)return;
if(ans)return;
for(int i=0;i=0&&nx=0&&nyt||(nx+ny+dx+dy+t)&1)
{
printf("NOn");continue;
}dfs(nx,ny,t);
if(ans)
printf("YESn");
else
printf("NOn");
}
return 0;
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: 为什么较小的SD卡可以做1T容量而同容量M.2固态却需更大体积?
SD卡和M.2固态之所以在体积上有所差异,主要是因为它们的内部结构和工作原理的不同所导致的。 SD卡是一种闪存卡,它的内部结构由许多纳米级的芯片组成。这些芯片可以在一个小小的空间内存储大量的数据,而且它们的密度非常高,所以SD卡可以做到很小,但存储容量却可以非…