ACM Ignatius and the Princess I
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的更多相关文章
- ACM Ignatius and the Princess II
Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the door and fin ...
- 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 ...
- 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 ...
- [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 ...
- ACM学习历程—HDU1028 Ignatius and the Princess(组合数学)
Ignatius and the Princess Description "Well, it seems the first problem is too easy. I w ...
- hdu 1026 Ignatius and the Princess I
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1026 Ignatius and the Princess I Description The Prin ...
- ACM-简单题之Ignatius and the Princess II——hdu1027
转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...
- 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 ...
- ACM-简单的主题Ignatius and the Princess II——hdu1027
转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...
随机推荐
- android 加速度传感器 ---摇一摇
package com.eboy.testyaoyiyao;import java.text.SimpleDateFormat;import java.util.Date;import android ...
- angularjs中的run()方法使用
run方法用于初始化全局的数据,仅对全局作用域起作用. 举个栗子吧:<script type="text/javascript"> var m1 = angular.m ...
- Linux下内存问题检测神器:Valgrind
在写大型C/C++工程时难免会发生内存泄漏现象,系统编程中一个重要的方面就是有效地处理与内存相关的问题.你的工作越接近系统,你就需要面对越多的内存问题.有时这些问题非常琐碎,而更多时候它会演变成一个调 ...
- docker 安装与学习
本文在CentsOS下安装Docker 1.安装前准备工作 系统要求: 在CentOS下需要64位的CentsOS 7 OS requirements To install Docker, you ...
- html学习之简单注册表单
<html> <head> <title>新用户注册</title> <meta charset="utf-8"> &l ...
- Flask博客开发——登录验证码
这部分为Flask博客的登录页面加个验证码.使用了PIL模块生成验证码图片,并通过Flask的session机制,进行验证码验证. 1.生成验证码 使用string模块:string.ascii_le ...
- 解决:HTTP 错误 404.0 - Not Found.您要找的资源已被删除、已更名或暂时不可用。(记录帖)
在IIS 上发布web程序时报错,HTTP 错误 404.0 - Not Found.您要找的资源已被删除.已更名或暂时不可用.在网上找了很多资料依然没有解决,后来问了一下同事,他一分钟就帮我搞定了 ...
- java中抽象类的概念
抽象类 public abstract class A{} 抽象类中可以定义抽象方法和普通方法:抽象方法指的是没有方法体的方法 public abtract void function();//抽象方 ...
- position的static、relative、absolute、fixed、inherit
网上有很多关于position的讲解,也有很多他们属性之间的比较,但是比较全面的讲解还是比较少,每次看完过段时间就忘了,所以今天参考了很多网上现有的资源,自己整理一下,写下这篇文章. position ...
- Pycharm数据库连接错误
简单地总结就一句话: Python2的mysql库为:mysqldb,而Python3的为:pymysql. 当我们使用Pycharm开发项目时,首先需要下载安装相对应的数据库,以及在项目根目录下的s ...