#P9735. [COCI 2022/2023 #2] Tramvaji
[COCI 2022/2023 #2] Tramvaji
Problem Description
Patrik and Josip are riding a tram. They ride for a total of stops.
At every stop after the boarding stop, exactly one of the following events happens upon arrival:
-
Patrik says: minutes have passed since we boarded.
-
Josip says: It took minutes to get here from stop .
Now, based on this information, find which two stops have the shortest travel time between them, and output that time.
Input Format
The input has lines.
The first line contains an integer (), the number of stops.
The next lines describe the event that happened at stop on line :
-
Type 1: ().
-
Type 2: (, ).
Each stop is at a different position.
Output Format
Output one line with three integers , , , representing the shortest time, and the start and end stops that achieve this shortest time.
If there are multiple answers, output the lexicographically smallest one.
4
Patrik 3
Patrik 5
Josip 1 7
2 2 3
2
Josip 1 5
5 1 2
5
Patrik 4
Josip 2 4
Josip 2 6
Josip 4 2
2 3 4
Hint
This problem uses bundled testdata.
| Score | Special properties | |
|---|---|---|
| Only events | ||
| None |
The full score for this problem is points.
Translated by ChatGPT 5