编程介的小学生 2017-11-29 05:24 采纳率: 20.5%
浏览 776
已采纳

Little White's Explore

Problem Description
Little White likes exploring. One day she finds a maze which has a shape of a rectangle of size n*m. The coordinate of the entrance is (1,1) and the precious deposits are place at (n,m).Except for these two positions, other grids' height change from time to time. At beginning,they all have the maximum height, and every second their height change by 1(increase or decrease). The grid cannot be stayed on if its height is smaller than min. Little White can jump upwards at most high meters and downwards low meters at a time. Every time, she can choose to go to the adjacent grids(up, down, left or right) or stay at the same grid. There is a lamp at grid (n,m) with height 10. Every time she jumps from i to j, she wishes to see the light of the lamp the moment she gets onto j. Little White has a height 10 and 100 units of power,which decrease by 1 unit for every second. It takes one second for her to jump from one grid to another, and the grids' height always change after her jump. She will always be at the center of the grids.

Input
For each data set:
The first line give five integers, n, m, min, high, low(2<=n,m<=35,min>=0,high>=0,low>=0).
The next n lines, each has m integers, indicating the grids' initial and maximum height.The height of the grid first decreases, then begins to increase when it gets to 0, and then begins to decrease when it gets maximum...

Output
Print the minimum time required to get to the precious deposits. If she cannot get to the destination, print -1 instead.

Sample Input
5 5 0 1 1
18 20 20 20 20
18 20 20 20 20
18 20 18 18 18
18 20 18 20 18
18 18 18 20 7
5 5 7 5 8
23 16 3 2 28
26 8 1 16 19
16 17 26 12 4
30 1 3 3 4
14 4 7 28 12

Sample Output
25
-1

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-12-26 15:11
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法