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 < N, M < 7; 0 < T < 50), which denote the sizes of the maze and the time at which the door will open, respectively. The next N lines give the maze layout, with each line containing M characters. A character is one of the following:

'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

醉了,,用广搜弄了半天,后面发现居然是第t秒到达;

痛苦,虽然错了,但还是保存一下代码吧;

 wrong answer代码::::注意
1 #include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
#define inf 1000000000
typedef pair<int, int > P;
int N, M, t, dis[][];
int bx, by, ex, ey;
char a[][];
int dd[][] = { {,},{,},{-,},{,-} };
int dfs()
{
for (int i = ; i < N; i++)
for (int j = ; j < M; j++) dis[i][j] = inf;
queue<P> p;
dis[bx][by] = ;
p.push(P(bx, by));
while (p.size())
{
P te = p.front(); p.pop();
if (te.first == ex && te.second == ey) break;
for (int i = ; i < ; i++)
{
int xx = te.first + dd[i][], yy = te.second+ dd[i][];
if (xx >= && xx < N &&yy >= && yy < M&&a[xx][yy]!='X'&&dis[xx][yy] == inf)
{
dis[xx][yy] = dis[te.first][te.second] + ;
p.push(P(xx, yy));
}
}
}
return dis[ex][ey];
}
int main()
{
int mis;
while (cin >> N >> M >> mis,N!=&&M!=&&mis!=)
{
for(int i = ;i<N ;i++)
for (int j = ; j < M; j++)
{
cin >> a[i][j];
if (a[i][j] == 'S')
bx = i, by = j;
if (a[i][j] == 'D')
ex = i, ey = j;
}
if (dfs() <= mis)
cout <<dfs() << endl;
else
cout << "NO" << endl;
}
return ;
}

1010:Tempter of the Bone的更多相关文章

  1. HDU 1010 Tempter of the Bone --- DFS

    HDU 1010 题目大意:给定你起点S,和终点D,X为墙不可走,问你是否能在 T 时刻恰好到达终点D. 参考: 奇偶剪枝 奇偶剪枝简单解释: 在一个只能往X.Y方向走的方格上,从起点到终点的最短步数 ...

  2. HDOJ.1010 Tempter of the Bone (DFS)

    Tempter of the Bone [从零开始DFS(1)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tem ...

  3. HDU 1010 Tempter of the Bone【DFS经典题+奇偶剪枝详解】

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  4. hdu 1010 Tempter of the Bone 奇偶剪枝

      如果所给的时间(步数) t 小于最短步数path,那么一定走不到. 若满足t>path.但是如果能在恰好 t 步的时候,走到出口处.那么(t-path)必须是二的倍数. 关于第二种方案的解释 ...

  5. hdu.1010.Tempter of the Bone(dfs+奇偶剪枝)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  6. hdu 1010:Tempter of the Bone(DFS + 奇偶剪枝)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  7. Hdu 1010 Tempter of the Bone 分类: Translation Mode 2014-08-04 16:11 82人阅读 评论(0) 收藏

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  8. hdoj 1010 Tempter of the Bone【dfs查找能否在规定步数时从起点到达终点】【奇偶剪枝】

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  9. hdu 1010 Tempter of the Bone 深搜+剪枝

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  10. hdu 1010 Tempter of the Bone(dfs)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

随机推荐

  1. git部分提交

    ---git add 需要提交的文件----git stash -u -k -k 开关告诉仓库保持文件的完整. -u 开关告诉仓库包括无路径的文件(那些新的和未添加到git的)----git stas ...

  2. Delete 和 Put 请求失效, Spring 框架

    Delete 和 Put 请求失效, Spring 框架 原因:使用tomcat 启动Spring项目的时候,请求失效.因为tomcat 不支持 Delete 和 Put 在 Web.xml 中增加下 ...

  3. Maven SSH三大框架整合的加载流程

    <Maven精品教程视频\day02视频\03ssh配置文件加载过程.avi;> 此课程中讲 SSH三大框架整合的加载流程,还可以,初步接触的朋友可以听一听. < \day02视频\ ...

  4. RPO攻击 & share your mind

    参考文章: https://xz.aliyun.com/t/2220 http://www.thespanner.co.uk/2014/03/21/rpo/ https://www.lorexxar. ...

  5. php编程 之 php基础一

    1,语法 PHP 脚本在服务器上执行,然后将纯 HTML 结果发送回浏览器.PHP 文件通常包含 HTML 标签和一些 PHP 脚本代码 比如下面这个:这是一个简单的 PHP 文件实例,它可以向浏览器 ...

  6. 【NLP CS224N笔记】汇总

    [NLP CS224N笔记]Lecture 1 - Introduction of NLP [NLP CS224N笔记]Lecture 2 - Word Vector Representations: ...

  7. Java 遍历List中删除的解决方法

  8. flask与数据库连接相关操作

    ---恢复内容开始--- 首先要安装  flask-sqlalchemy 数据库连接设置 在flask-SQLAlchemy中,数据库使用URL指定,而且程序使用的数据库必须保存到flask配置对象的 ...

  9. requests库入门05-参数类型

    一个接口基本都需要传入参数,有的参数必填,有的不必填. params参数 使用params参数来传递接口所需要的参数.一般用在get请求中,url参数是通过?拼接,?前面是接口的地址,之后是请求的参数 ...

  10. linux系统弱密码检测

    需要自备弱密码明文字典 from _utils.patrol2 import data_format,report_format,run_cmd import platform import cryp ...