Problem 1670. -- [Usaco2005 OCT]skiing 滑雪

1670: [Usaco2005 OCT]skiing 滑雪

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 4  Solved: 0
[Submit][Status][Web Board]

Description

Bessie and the rest of Farmer John's cows are taking a trip this
winter to go skiing. One day Bessie finds herself at the top left
corner of an R (1 <= R <= 100) by C (1 <= C <= 100) grid of elevations
E (-25 <= E <= 25). In order to join FJ and the other cows at a
discow party, she must get down to the bottom right corner as quickly
as she can by travelling only north, south, east, and west.
Bessie starts out travelling at a initial speed V (1 <= V <=
1,000,000). She has discovered a remarkable relationship between
her speed and her elevation change. When Bessie moves from a
location of height A to an adjacent location of height B, her speed
is multiplied by the number 2^(A-B). The time it takes Bessie to
travel from a location to an adjacent location is the reciprocal
of her speed when she is at the first location.
Find the both smallest amount of time it will take Bessie to join
her cow friends and the number of moves required by the path (a
move is a transition from one location to another adjacent location).

Bessie 在一个矩形区域内滑雪，她的起始位置为矩形的左上角，给出初始速度v，

Input

* Line 1: Three space-separated integers: V, R, and C, which
respectively represent Bessie's initial velocity and the
number of rows and columns in the grid.
* Lines 2..R+1: C integers representing the elevation E of the
corresponding location on the grid.

Output

A single number value, printed to two exactly decimal places: the
minimum amount of time that Bessie can take to reach the bottom right
corner of the grid.

Sample Input

1 3 3  //奶牛开始在左上角，速度为1,它可以移动到别的格子上，速度会发生变化
1 5 3 //这个3*3的数矩阵代表每个格子的参数，当从一个格子A到B时，速度变成V*2^(A-B)
6 3 5
2 4 3

Sample Output

29.00
OUTPUT DETAILS:
Bessie's best route is:
Start at 1,1 time  0 speed 1
East  to 1,2 time  1 speed 1/16
South to 2,2 time 17 speed 1/4
South to 3,2 time 21 speed 1/8
East  to 3,3 time 29 speed 1/4

[Submit][Status]