#abc368e. E - Train Delay
E - Train Delay
Score : points
问题陈述
在Atcoder国,有个城市,编号从到,以及列火车,编号从到。第列火车从城市出发,出发时间为,到达城市,到达时间为。
给定一个正整数,找到一种方法来设置非负整数,使得满足以下条件的的值尽可能小。
- 条件:对于所有满足的对,如果且,则。
- 换句话说,对于任何一对原本可以换乘的火车,即使在延迟了每列火车的出发和到达时间之后,仍然可以换乘。
可以证明,设置的方法,使得的值尽可能小是唯一的。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
In the nation of Atcoder, there are cities numbered to , and trains numbered to . Train departs from city at time and arrives at city at time .
Given a positive integer , find a way to set non-negative integers that satisfies the following condition with the minimum possible value of .
- Condition: For all pairs satisfying , if and , then .
- In other words, for any pair of trains that are originally possible to transfer between, it is still possible to transfer even after delaying the departure and arrival times of each train by .
It can be proved that such a way to set with the minimum possible value of is unique.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print that satisfy the condition with the minimum possible sum, in that order, separated by spaces.
Sample Input 1
3 6 15
1 2 10 20
1 2 20 30
2 3 25 40
2 3 35 50
3 1 15 30
3 1 45 60
Sample Output 1
0 10 0 0 5
The arrival of train from city to is delayed by and becomes time .
To allow transfer from train to in city , the departure of train is delayed by , making it depart at time and arrive at time .
Further, to allow transfer from train to in city , the departure of train is delayed by , making it depart at time .
Other trains can operate without delay while still allowing transfers between originally transferable trains, so satisfies the condition.
Moreover, there is no solution with a smaller sum that satisfies the condition, so this is the answer.
Sample Input 2
10 9 100
1 10 0 1
10 2 1 100
10 3 1 100
10 4 1 100
10 5 1 100
10 6 1 100
10 7 1 100
10 8 1 100
10 9 1 100
Sample Output 2
100 100 100 100 100 100 100 100
Sample Input 3
4 4 10
1 2 0 1
1 2 0 10
2 3 100 200
2 4 100 200
Sample Output 3
0 0 0