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. nnet3中的数据类型

    目标与背景 之前的nnet1和nnet2基于Component对象,是一个组件的堆栈.每个组件对应一个神经网络层,为简便起见,将一个仿射变换后接一个非线性表示为一层网络,因此每层网络有两个组件.这些旧 ...

  2. ng directive compile pre-link post-link

    原文链接: http://www.jb51.net/article/58229.htm 1.ng在link之前编译所有的指令,然后link又分为 pre-link 与 post-link阶段compi ...

  3. jq的error

    error事件会在js发生错误或资源加载失败时触发.该事件主要用于window对象.<img>等元素. 此外,你可以为同一元素多次调用该函数,从而绑定多个事件处理函数.触发error事件时 ...

  4. mysql 分库分表 ~ 方案选择浅谈

    一 简介:分库分表的理解二 具体: 1 当由于单台DB业务增长导致的服务器压力时,就必须横向进行扩展              2 本文仅从中间层观点进行分析三 现有方案  方案1 sharding家 ...

  5. 基于ip的虚拟主机配置——在一台服务器上绑定多个 IP 地址

    进入/etc/sysconfig/network-scripts,修改ifcfg-ens33文件 输入 ip addr 查看ip 引用:https://blog.csdn.net/u013887008 ...

  6. CF1091E New Year and the Acquaintance Estimation

    题目地址:CF1091E New Year and the Acquaintance Estimation 首先,易知 \(ans\) 的奇偶性与所有给出的数的和的奇偶性相同 其次,易证 \(ans\ ...

  7. Tomcat安装7.0.91

    版本升级,JDK 1.7,Tomcat从7.0.73升级到7.0.91 为什么升级?解决安全漏洞! 升级就正常流程,下载*.tar.gz ,解压,改配置. 但碰到神奇的坑: 1.server.xml中 ...

  8. LwIP Application Developers Manual4---传输层之UDP、TCP

    1.前言 本文主要讲解传输层协议UDP TCP 2.UDP 2.1 UDP from an application perspective 2.2 UDP support history in lwI ...

  9. 设计模式C++学习笔记之五(Factory Method工厂方法模式)

      工厂方法模式的意义是定义一个创建产品对象的工厂接口,将实际创建工作推迟到子类当中.核心工厂类不再负责产品的创建,这样核心类成为一个抽象工厂角色,仅负责具体工厂子类必须实现的接口,这样进一步抽象化的 ...

  10. 关于session,cookie,Cache

    昨天看了<ASP.NET 页面之间传值的几种方式>之后,对session,cookie,Cache有了更近一步的了解,以下是相关的内容 一.Session 1.Session基本操作 a. ...