#AT1333. [ABC164E] Two Currencies
[ABC164E] Two Currencies
题目描述
现在有 个编号从 到 的城市,由 条铁路连接。
你现在在城市 ,口袋里有 个金币和 个银币。
第条铁路双向连接城市 和城市 ,一次旅行需要消耗 个银币并花费 分钟。
你不能用金币支付车费。
每个城市都有一个兑换柜台。在城市的兑换柜台,你可以用 个金币兑换得到 个银币。
兑换每个金币需要花费 分钟。
你可以在每个兑换柜台兑换任意数量的金币,对于每个,找出从城市 到城市的最少时间。
可以忽略等待车的时间。
输入格式
- 第一行
- 接下来 行
- 接下来 行
输出格式
按照这个顺序,对每个,打印一个包含从城市 到城市所需最少时间的行。
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 of the city ( for City )
- The second line: /
Similarly, each railroad is labeled as follows:
- The first line: the ID number of the railroad ( for the -th railroad in input)
- The second line: /
You can travel from City to City in minutes, as follows:
- Use the -st railroad to move from City to City in minutes.
You can travel from City to City in minutes, as follows:
- Use the -st railroad to move from City to City in minutes.
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -st railroad to move from City to City in minutes.
- Use the -nd railroad to move from City to City in 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:
You can travel from City to City in minutes, as follows:
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -nd railroad to move from City to City in minutes.
- Use the -th railroad to move from City to City in 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:
You can travel from City to City in minutes, as follows:
- Use the -st railroad to move from City to City in minute.
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -st railroad to move from City to City in minute.
- Use the -nd railroad to move from City to City in minute.
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -nd railroad to move from City to City in minute.
- Use the -st railroad to move from City to City in minute.
- Use the -rd railroad to move from City to City in minute.
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -rd railroad to move from City to City in minute.
- Use the -st railroad to move from City to City in minute.
- Use the -nd railroad to move from City to City in minute.
- Use the -th railroad to move from City to City in minute.
- At the exchange counter in City , exchange gold coins for silver coins in minutes.
- Use the -th railroad to move from City to City in minute.
- Use the -nd railroad to move from City to City in minute.
- Use the -th railroad to move from City to City in 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:
2 1 0
1 2 1 1
1 1000000000
1 1
1000000001
The railway network in this input is shown in the figure below:
You can travel from City to City in minutes, as follows:
- At the exchange counter in City , exchange gold coin for silver coin in minutes.
- Use the -st railroad to move from City to City in minute.
提示
- 没有一对 满足
- 都每个城市 可以由城市 通过一些铁路到达。
- 输入中的所有值都是整数