#1744. [Usaco2005 oct]Skiing 奶牛滑雪

[Usaco2005 oct]Skiing 奶牛滑雪

题目描述

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 (1r100)r \ (1 \le r \le 100) by c (1c100)c \ (1 \le c \le 100) grid of elevations e (25e25)e \ (-25 \le e \le 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 (1v106)v \ (1 \le v \le 10^6). She has discovered a remarkable relationship between her speed and her elevation change. When Bessie moves from a location of height aa to an adjacent location of height bb, her speed is multiplied by the number 2ab2^{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).

贝茜和其他一些人去滑雪。贝茜发现她自己站在一块 r×cr \times c 的区域中,区域中的每一块都有一个高度值 ei,je_{i,j}。为了参加大家的聚会,贝茜想要尽快到达右下角。贝茜每一步只能向正东,正西,正南,正北前进一步。贝茜以初速度 vv 前进,她发现了一个她的速度和高度的关系。当贝茜从高度 aa 移动到高度 bb,她的速度就乘上了一个数 2ab2^{a-b}。贝茜移动一步的速度取决于她在前一格时的速度。请找出贝茜移动所需的最小时间。

输入格式

  • Line 11: Three space-separated integers: v,rv,r, and cc, which respectively represent Bessie's initial velocity and the number of rows and columns in the grid.
  • Lines 2r+12\dots r+1: cc integers representing the elevation ee of the corresponding location on the grid.
  • 第一行:33 个用空格隔开的整数 v,r,cv,r,c,分别表示贝茜的初速度和区域的长度和宽度。
  • 第二到 r+1r+1 行:以矩阵的形式表示该区域中各块的高度。

输出格式

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.
输出一个实数(保留 22 位小数),表示贝茜达到目的地最少需要的时间。

1 3 3
1 5 3
6 3 5
2 4 3
29.00

样例说明

奶牛开始在左上角,速度为 11,它可以移动到别的格子上,速度会发生变化。
3×33\times 3 的数矩阵代表每个格子的参数,当从一个格子 aabb 时,速度变成 v×2abv\times 2^{a-b}

OUTPUT DETAILS:
Bessie's best route is:
Start at  (1,1)\ (1,1) time 00 speed 11.
East to  (1,2)\ (1,2) time 11 speed 116\dfrac{1}{16}.
South to  (2,2)\ (2,2) time 1717 speed 14\dfrac{1}{4}.
South to  (3,2)\ (3,2) time 2121 speed 18\dfrac{1}{8}.
East to  (3,3)\ (3,3) time 2929 speed 14\dfrac{1}{4}.

数据规模与约定

对于 100%100\% 的数据,1r,c1001 \leq r,c \leq 10025ei,j25-25 \le e_{i,j} \le 251v1061 \leq v \leq 10^6

题目来源

Gold