#abc222f. F - Expensive Expense
F - Expensive Expense
Score : points
问题描述
AtCoder王国由个城镇和条道路组成。
这些城镇分别标记为城镇1、城镇2、…、城镇。类似地,道路被标记为道路1、道路2、…、道路。道路在城镇和之间双向连接,通过它需要支付的通行费。对于每一对不同的城镇,都可以通过道路从城镇到达城镇。
你得到了一个序列,其中是在城镇观光的成本。让我们定义从城镇到城镇的旅行成本为从城镇到城镇过程中所发生的全部通行费加上。
- 更正式地说,被定义为,其中从到的最短路径为,连接城镇和的道路的通行费为。
对于每个,求出从城镇出发前往另一个城镇的最大可能旅行成本。
- 更正式地讲,对于每一个,求出。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
The Kingdom of AtCoder is composed of towns and roads.
The towns are labeled as Town , Town , , Town . Similarly, the roads are labeled as Road , Road , , Road . Road connects Towns and bidirectionally, and you have to pay the toll of to go through it. For every pair of different towns , it is possible to go from Town to Town via the roads.
You are given a sequence , where is the cost to do sightseeing in Town . Let us define the travel cost from Town to Town as the total toll incurred when going from Town to Town , plus .
- More formally, is defined as , where the shortest path between and is and the toll for the road connecting Towns and is .
For every , find the maximum possible travel cost when traveling from Town to another town.
- More formally, for every , find .
Constraints
- It is possible to travel from Town to Town via some number of roads, for a pair of integers such that .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain $\displaystyle \max_{1 \leq j \leq N, j \neq i} E_{i,j}$.
Sample Input 1
3
1 2 2
2 3 3
1 2 3
Sample Output 1
8
6
6
The value of for every ordered pair of towns is as follows.
Sample Input 2
6
1 2 3
1 3 1
1 4 4
1 5 1
1 6 5
9 2 6 5 3 100
Sample Output 2
105
108
106
109
106
14
Sample Input 3
6
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
1 2 3 4 5 6
Sample Output 3
5000000006
4000000006
3000000006
3000000001
4000000001
5000000001
update @ 2024/3/10 09:48:01