#abc325e. E - Our clients, please wait a moment

E - Our clients, please wait a moment

Score : 450450 points

问题陈述

在某国家有 NN 个城市。
你将从城市 1 的办公室出发,经过零个或多个城市到达城市 NN 的目的地。
有两种交通工具可供选择:公司汽车和火车。从城市 ii 到城市 jj 所需的时间如下:

  • 乘坐公司汽车所需时间为 Di,j×AD_{i,j} \times A 分钟,
  • 乘坐火车所需时间为 Di,j×B+CD_{i,j} \times B + C 分钟。

你可以从公司汽车换乘到火车,但不能反过来。
你可以在不花费时间的情况下进行换乘,但只能在城市中进行。

请问从城市 1 到城市 NN 的最短旅行时间是多少分钟?

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN cities in a certain country.
You will travel from your office in city 11 to a destination in city NN, via zero or more cities.
Two types of transportation are available: company car and train. The time required to travel from city ii to city jj is as follows:

  • Di,j×AD_{i,j} \times A minutes by company car, and
  • Di,j×B+CD_{i,j} \times B + C minutes by train.

You can switch from company car to train, but not vice versa.
You can do so without spending time, but only in a city.

What is the minimum time in minutes to travel from city 11 to city NN?

Constraints

  • 2N10002 \leq N \leq 1000
  • 1A,B,C1061 \leq A, B, C \leq 10^6
  • Di,j106D_{i,j} \leq 10^6
  • Di,i=0D_{i,i} = 0
  • Di,j=Dj,i>0D_{i,j} = D_{j,i} > 0 (ij)(i \neq j)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN AA BB CC

D1,1D_{1,1} D1,2D_{1,2} \ldots D1,ND_{1,N}

D2,1D_{2,1} D2,2D_{2,2} \ldots D2,ND_{2,N}

\vdots

DN,1D_{N,1} DN,2D_{N,2} \ldots DN,ND_{N,N}

Output

Print the answer as an integer.

Sample Input 1

4 8 5 13
0 6 2 15
6 0 3 5
2 3 0 13
15 5 13 0

Sample Output 1

78

You can travel from city 11 to city 44 in a total of 7878 minutes by moving as follows.

  • Travel by company car from city 11 to city 33. This takes 2×8=162 \times 8 = 16 minutes.
  • Travel by company car from city 33 to city 22. This takes 3×8=243 \times 8 = 24 minutes.
  • Travel by train from city 22 to city 44. This takes 5×5+13=385 \times 5 + 13 = 38 minutes.

It is impossible to travel from city 11 to city 44 in less than 7878 minutes.

Sample Input 2

3 1 1000000 1000000
0 10 1
10 0 10
1 10 0

Sample Output 2

1

Sample Input 3

5 954257 954213 814214
0 84251 214529 10017 373342
84251 0 91926 32336 164457
214529 91926 0 108914 57762
10017 32336 108914 0 234705
373342 164457 57762 234705 0

Sample Output 3

168604826785

update @ 2024/3/10 01:48:18

}