编程介的小学生 2017-11-22 08:43 采纳率: 20.5%
浏览 714
已采纳

Huson's Adventure Island

roblem Description
A few days ago, Tom was tired of all the PC-games, so he went back to some old FC-games. "Hudson's Adventure Island" was his favorite which he had played thousands of times. But to his disappointed, the more he played, the more he lost. Tom soon gave up the game.

Now, he invents an easier game on the base of “Hudson's Adventure Island”. He wants to know whether the new game is easy enough. So he came to you for help.
To simplify the problem, you can assume there is matrix-map contains m(0 < m < 256) rows, n(0 < n < 256) columns, an entrance on the top-left corner (0, 0), an exit on the bottom-right corner (m-1, n-1). Each entry of the matrix contains a integer k.The range of k is defined below:
a)k = 0,it is a free space one can go through.
b)k = -1,it is an obstacle one can’t go through.
c)0 < k < 10000,it is a fruit one can go through and gain k points of energy.
d)k >= 0 at the entrance point and the end point.
At the begin, the hero has 0 points of energy and he can go four directions (up, down, left, right). Each move he makes cost 1 point of energy. No energy no move. If he can’t make a move or get to the exit, he loses the game. The number of fruit is 17 at most.

Input
The input consists of multiple test cases. Each test case starts with two positive integers m, n. Then follows m lines, each line contain n integers.

Output
For each case, if the hero can get the exit, find and print the maximum points of energy he left. Or print “you loss!”

Sample Input
4 4
8 0 0 0
-1 -1 -1 0
-1 -1 -1 0
0 6 0 0
3 3
4 0 0
0 0 0
0 0 0
4 4
5 0 0 0
0 -1 -1 0
0 -1 -1 0
0 0 0 0

Sample Output
4
0
you loss!

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-07-27 12:05
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决