1010:Tempter of the Bone
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.
'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.
S.X.
..X.
..XD
....
3 4 5
S.X.
..X.
...D
0 0 0
醉了,,用广搜弄了半天,后面发现居然是第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的更多相关文章
- HDU 1010 Tempter of the Bone --- DFS
HDU 1010 题目大意:给定你起点S,和终点D,X为墙不可走,问你是否能在 T 时刻恰好到达终点D. 参考: 奇偶剪枝 奇偶剪枝简单解释: 在一个只能往X.Y方向走的方格上,从起点到终点的最短步数 ...
- HDOJ.1010 Tempter of the Bone (DFS)
Tempter of the Bone [从零开始DFS(1)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tem ...
- 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 ...
- hdu 1010 Tempter of the Bone 奇偶剪枝
如果所给的时间(步数) t 小于最短步数path,那么一定走不到. 若满足t>path.但是如果能在恰好 t 步的时候,走到出口处.那么(t-path)必须是二的倍数. 关于第二种方案的解释 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- hdu 1010 Tempter of the Bone 深搜+剪枝
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- 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 ...
随机推荐
- linux下socket的连接队列的 backlog的分析
建立socket连接的过程 1:client发syn请求给server 2:server收到后把请求放在syn queue中,这个半连接队列的最大值是系统参数tcp_max_syn_backlog定义 ...
- Socket与TCP,UDP
什么是socket 简单来说是IP地址与端口的结合协议(RFC 793) 一种地址与端口的结合描述协议 TCP/IP协议的 相关API的总称:是网络api的集合实现 涵盖了:Stream Socket ...
- 6-12mysql库的操作
1,mysql库的各种分类: nformation_schema: 虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限信息.字符信息等. performance_sch ...
- LR-Controller 如何自定义显示虚拟用户状态
我们压测时,如何直观,实时地查看当前运行账号和迭代情况呢. 在运行脚本中添加一行代码就解决了~~~~~~~~~~~
- linux 日志管理
- Microsoft SQL - 查询与更新
查询与更新(Query & Update) 转义引号 SQL语句中字符串只能使用单引号,如果需要转义,可用单引号转义单引号. 查询(Inquire) 以下公式中的c指代列名. 规则 1.查询语 ...
- 20165337 2017-2018-2《Java程序设计》课程总结
一.每周作业链接汇总 预备作业一:我期望的师生关系 简要内容: 读完文章的感想 我印象深刻的老师 我期望的师生关系 预备作业二:学习基础和C语言基础调查 简要内容: 你有什么技能比大多人(超过90%以 ...
- Oracle 服务器运行健康状况监控利器 Spotlight on Oracle 的安装与使用
1.使用教程;https://blog.csdn.net/defonds/article/details/52936664 2.下载链接:https://pan.baidu.com/s/1cn7tE_ ...
- hadoop-1.2.1集群搭建
继续上一篇:http://www.cnblogs.com/CoolJayson/p/7430654.html 首先需要安装上台虚拟机, 分别为: master, salve1, slave2 1.复制 ...
- 【C++】一篇文章,让你不再害怕指针
在C++中,比较难以理解的就是指针,最常用的也是指针.这篇文章,结合我的所学,所看,来谈谈C++中的指针 指针是什么 指针是一个特殊的变量,指向内存中的一个地址.它具有四个要素: 指针类型:即指针本身 ...