公主被BEelzebub feng5166绑架,我们的英雄Ignatius必须拯救我们美丽的公主。 现在他进入feng5166的城堡。城堡是一个大迷宫。为简单起见,( To make the problem simply, )我们假设迷宫是一个N * M二维数组,左上角是(0,0),右下角是(N-1,M-1)。 Ignatius进入(0,0),feng5166的房间的门是(N-1,M-1),这是我们的目标。城堡里有一些怪物,如果Ignatius遇见他们,他必须杀死他们。这里有一些规则:

1.Ignatius只能在四个方向(上,下,左,右)移动,每秒一步。步骤定义如下:如果当前位置是(x,y),步骤之后,Ignatius只能站立(x-1,y),(x + 1,y),(x,y-1)或(X,Y + 1)。
2.数组标有一些字符和数字。我们定义如下: 
. : Ignatius可以走的地方
X :这个地方是一个陷阱,Ignatius不应该走在它上面。
n : 这是一个n HP(1 <= n <= 9)的怪物,如果Ignatius走在上面,则需要他n秒才能杀死怪物。
您的任务是发出Ignatius到达目标位置的最小秒数的路径。你可以假设起始位置和目标位置永远不会成为陷阱,在起始位置永远不会有怪物。

Input

该输入包含几个测试用例。每个测试用例以包含两个数字N和M(2 <= N <= 100,2 <= M <= 100)的行开始,表示迷宫的大小。然后是一个N * M二维阵列,它描述了整个迷宫。输入结束文件结束。样品输入中的更多细节。
Output

对于每个测试用例,如果Ignatius不能达到目标位置,你应该输出 "God please help our poor hero."  或者你应该输出"It takes n seconds to reach the target position, let me show you the way."(n is the minimum seconds), 告诉我们的英雄的整个路径。在每个测试用例之后输出一行包含“FINISH”。 如果有不止一个路径,任何一个都可以在这个问题。样品输出中的更多细节。

Sample Input

5 6
.XX.1.
..X.2.
2...X.
...XX.
XXXXX.
5 6
.XX.1.
..X.2.
2...X.
...XX.
XXXXX1
5 6
.XX...
..XX1.
2...X.
...XX.
XXXXX.

Sample Output

It takes 13 seconds to reach the target position, let me show you the way.
1s:(0,0)->(1,0)
2s:(1,0)->(1,1)
3s:(1,1)->(2,1)
4s:(2,1)->(2,2)
5s:(2,2)->(2,3)
6s:(2,3)->(1,3)
7s:(1,3)->(1,4)
8s:FIGHT AT (1,4)
9s:FIGHT AT (1,4)
10s:(1,4)->(1,5)
11s:(1,5)->(2,5)
12s:(2,5)->(3,5)
13s:(3,5)->(4,5)
FINISH
It takes 14 seconds to reach the target position, let me show you the way.
1s:(0,0)->(1,0)
2s:(1,0)->(1,1)
3s:(1,1)->(2,1)
4s:(2,1)->(2,2)
5s:(2,2)->(2,3)
6s:(2,3)->(1,3)
7s:(1,3)->(1,4)
8s:FIGHT AT (1,4)
9s:FIGHT AT (1,4)
10s:(1,4)->(1,5)
11s:(1,5)->(2,5)
12s:(2,5)->(3,5)
13s:(3,5)->(4,5)
14s:FIGHT AT (4,5)
FINISH
God please help our poor hero.
FINISH

ACM Ignatius and the Princess I的更多相关文章

  1. ACM Ignatius and the Princess II

    Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the door and fin ...

  2. hdu acm 1028 数字拆分Ignatius and the Princess III

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  3. ACM: HDU 1028 Ignatius and the Princess III-DP

     HDU 1028 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Form ...

  4. [ACM] hdu 1029 Ignatius and the Princess IV (动归或hash)

    Ignatius and the Princess IV Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32767K (Ja ...

  5. ACM学习历程—HDU1028 Ignatius and the Princess(组合数学)

    Ignatius and the Princess Description        "Well, it seems the first problem is too easy. I w ...

  6. hdu 1026 Ignatius and the Princess I

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1026 Ignatius and the Princess I Description The Prin ...

  7. ACM-简单题之Ignatius and the Princess II——hdu1027

    转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...

  8. hdu 1026 Ignatius and the Princess I【优先队列+BFS】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1026 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  9. ACM-简单的主题Ignatius and the Princess II——hdu1027

    转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...

随机推荐

  1. [NOIP2009][LuoguP1073] 最优贸易 - Tarjan,拓扑+DP

    Description&Data 题面:https://www.luogu.org/problemnew/show/P1073 Solution Tarjan对联通块缩点,在DAG上按照拓扑序 ...

  2. python的调试

    调试 程序能一次写完并正常执行的概率很小.总会有各种各样的bug需要修正. 有的bug很简单,看看错误信息就知道,有的bug很复杂,我们需要知道出错时 哪些变量的值是正确的,哪些变量的值是错误的,因此 ...

  3. scrapy spider官方文档

    Spiders Spider类定义了如何爬取某个(或某些)网站.包括了爬取的动作(例如:是否跟进链接)以及如何从网页的内容中提取结构化数据(爬取item). 换句话说,Spider就是您定义爬取的动作 ...

  4. Jenkins的安装

    安装环境: 512M内存 10G硬盘空间 Java 8环境 先来创建jenkins的运行目录: mkdir /data/jenkins && cd /data/jenkins 下载je ...

  5. maven项目添加db2的jar包

    安装完DB2后,SQLLIB文件夹下的java目录下有对应的jar包,我的SQLLIB文件夹位置在 D:\Program Files\IBM\SQLLIB\java 处. 此目录直接添加到CLASSP ...

  6. 使用javaMail实现简单邮件发送

    一.首先你要用来发送邮件的qq邮箱需要开通pop3/smtp服务,这个可以百度一下就知道了 二.导入所需要的jar包,我使用的是maven添加依赖 <dependency> <gro ...

  7. JavaScript数据结构与算法(一) 栈的实现

    TypeScript版本源码 class Stack { items = []; public push(element) { this.items.push(element); } public p ...

  8. 0417 jsBom操作+Dom再次整理

    BOM 1.Windows对象 window.open("打开的地址","打开的位置")window.opener:打开此页面的上一个页面对象window.cl ...

  9. Python的基础学习(第二周)

    模块初始 sys模块 import sys sys.path #打印环境变量 sys.argv#打印该文件路径 #注意:该文件名字不能跟导入模块名字相同 os模块 import os cmd_res ...

  10. 【Android学习笔记】布局的简单介绍

    我在学习Android开发的时候是基于实战项目的,基础理论知识以前也是零散的看过一些,个人还是觉得边做项目边学要快些.现在做的这个项目iOS端是我做的,这样逻辑什么的都很熟悉,于我而言换个平台也只是换 ...