#AT1333. [ABC164E] Two Currencies

[ABC164E] Two Currencies

题目描述

现在有 NN 个编号从 11NN 的城市,由 MM 条铁路连接。

你现在在城市 11,口袋里有 1010010^{100} 个金币和 SS 个银币。

ii条铁路双向连接城市 UiU-i和城市ViV_i ,一次旅行需要消耗 AiA_i个银币并花费 BiB_i分钟。

你不能用金币支付车费。

每个城市都有一个兑换柜台。在城市ii的兑换柜台,你可以用 11 个金币兑换得到 CiC_i个银币。

兑换每个金币需要花费 DiD_i分钟。

你可以在每个兑换柜台兑换任意数量的金币,对于每个t=2,,Nt= 2,…,N,找出从城市11 到城市tt的最少时间。

可以忽略等待车的时间。

输入格式

  • 第一行 n,m,sn,m,s
  • 接下来 mmui,vi,xi,tiu_i,v_i,x_i,t_i
  • 接下来 nnci,dic_i,d_i

输出格式

按照这个顺序,对每个t=2,,Nt= 2,…, N,打印一个包含从城市11 到城市tt所需最少时间的行。

3 2 1
1 2 1 2
1 3 2 4
1 11
1 2
2 5
2
14

The railway network in this input is shown in the figure below.

In this figure, each city is labeled as follows:

  • The first line: the ID number ii of the city (ii for City ii)
  • The second line: CiC_i / DiD_i

Similarly, each railroad is labeled as follows:

  • The first line: the ID number ii of the railroad (ii for the ii-th railroad in input)
  • The second line: AiA_i / BiB_i

Figure

You can travel from City 11 to City 22 in 22 minutes, as follows:

  • Use the 11-st railroad to move from City 11 to City 22 in 22 minutes.

You can travel from City 11 to City 33 in 1414 minutes, as follows:

  • Use the 11-st railroad to move from City 11 to City 22 in 22 minutes.
  • At the exchange counter in City 22, exchange 33 gold coins for 33 silver coins in 66 minutes.
  • Use the 11-st railroad to move from City 22 to City 11 in 22 minutes.
  • Use the 22-nd railroad to move from City 11 to City 33 in 44 minutes.
4 4 1
1 2 1 5
1 3 4 4
2 4 2 2
3 4 1 1
3 1
3 1
5 2
6 4
5
5
7

The railway network in this input is shown in the figure below:

Figure

You can travel from City 11 to City 44 in 77 minutes, as follows:

  • At the exchange counter in City 11, exchange 22 gold coins for 66 silver coins in 22 minutes.
  • Use the 22-nd railroad to move from City 11 to City 33 in 44 minutes.
  • Use the 44-th railroad to move from City 33 to City 44 in 11 minutes.
6 5 1
1 2 1 1
1 3 2 1
2 4 5 1
3 5 11 1
1 6 50 1
1 10000
1 3000
1 700
1 100
1 1
100 1
1
9003
14606
16510
16576

The railway network in this input is shown in the figure below:

Figure

You can travel from City 11 to City 66 in 1657616576 minutes, as follows:

  • Use the 11-st railroad to move from City 11 to City 22 in 11 minute.
  • At the exchange counter in City 22, exchange 33 gold coins for 33 silver coins in 90009000 minutes.
  • Use the 11-st railroad to move from City 22 to City 11 in 11 minute.
  • Use the 22-nd railroad to move from City 11 to City 33 in 11 minute.
  • At the exchange counter in City 33, exchange 88 gold coins for 88 silver coins in 56005600 minutes.
  • Use the 22-nd railroad to move from City 33 to City 11 in 11 minute.
  • Use the 11-st railroad to move from City 11 to City 22 in 11 minute.
  • Use the 33-rd railroad to move from City 22 to City 44 in 11 minute.
  • At the exchange counter in City 44, exchange 1919 gold coins for 1919 silver coins in 19001900 minutes.
  • Use the 33-rd railroad to move from City 44 to City 22 in 11 minute.
  • Use the 11-st railroad to move from City 22 to City 11 in 11 minute.
  • Use the 22-nd railroad to move from City 11 to City 33 in 11 minute.
  • Use the 44-th railroad to move from City 33 to City 55 in 11 minute.
  • At the exchange counter in City 55, exchange 6363 gold coins for 6363 silver coins in 6363 minutes.
  • Use the 44-th railroad to move from City 55 to City 33 in 11 minute.
  • Use the 22-nd railroad to move from City 33 to City 11 in 11 minute.
  • Use the 55-th railroad to move from City 11 to City 66 in 11 minute.
4 6 1000000000
1 2 50 1
1 3 50 5
1 4 50 7
2 3 50 2
2 4 50 4
3 4 50 3
10 2
4 4
5 5
7 7
1
3
5

The railway network in this input is shown in the figure below:

Figure

2 1 0
1 2 1 1
1 1000000000
1 1
1000000001

The railway network in this input is shown in the figure below:

Figure

You can travel from City 11 to City 22 in 10000000011000000001 minutes, as follows:

  • At the exchange counter in City 11, exchange 11 gold coin for 11 silver coin in 10000000001000000000 minutes.
  • Use the 11-st railroad to move from City 11 to City 22 in 11 minute.

提示

  • 2  N  50 2\ \leq\ N\ \leq\ 50
  • N1  M  100 N-1\ \leq\ M\ \leq\ 100
  • 0  S  109 0\ \leq\ S\ \leq\ 10^9
  • 1  Ai  50 1\ \leq\ A_i\ \leq\ 50
  • 1  Bi,Ci,Di  109 1\ \leq\ B_i,C_i,D_i\ \leq\ 10^9
  • 1  Ui < Vi  N 1\ \leq\ U_i\ <\ V_i\ \leq\ N
  • 没有一对 i,j(i  j) i,j(i\ \neq\ j) 满足 (Ui,Vi)=(Uj,Vj) (U_i,V_i)=(U_j,V_j)
  • 都每个城市 t=2,...,Nt=2,...,N 可以由城市 11 通过一些铁路到达。
  • 输入中的所有值都是整数