编程介的小学生 2017-12-01 12:05 采纳率: 20.5%
浏览 863
已采纳

Save XX

Problem Description
Once a day, XX has been caught by evil Z. WisKey, our team leader, has to rescue her. They have escaped from Z’s castle. But unfortunately, they lost in the forest. What’s more, this forest is a big maze. There is only one place to leave. Z is familiar with the forest, and he will arrive at the place in T minutes.
To make the problem simply, we assume the forest is a N*M two-dimensional array which left-top corner is (0,0) and right-bottom corner is (N-1,M-1). The place they stayed now is marked S , and the place to leave is marked E. They could only move to empty place in four directions (up, down , left, right ), or stay at the place.

. : empty
X: the tree
S: the place Wiskey and XX now stay
E: the place to leave
Your task is to give out whether they can escape.

Input
The input contains several test cases. Each test case starts with a line contains three number N ,M (2<= N <= 100, 2 <= M <= 100 ) indicate the size of the maze, T (2 <= T <= 20) indicate the time Z cost to arrive at E place. Then N lines follows, each line contains M character. A S and a E will be in the map.

Output
For each test case, you should print the number of different ways to arrive at the E place, if they can arrive at E place before T minutes. And you should print “Oh, my god, bad luck!”, if they arrive at E place at the same time with Z, because Z will catch them. Otherwise, “God will bless XX and WisKey!” should be printed.

Sample Input
5 6 4
XXXX..
XS.X..
XX.XXX
XX..EX
XXXXXX
5 6 5
XXXX..
XS.X..
XX..XX
XX..EX
XXXXXX
5 6 6
XXXX..
XS.X..
XX..XX
XX..EX
XXXXXX

Sample Output
God will bless XX and WisKey!
Oh, my god, bad luck!
2

  • 写回答

1条回答

  • threenewbee 2017-12-01 15:32
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题