#P17382. [PacNW 2025] Farthest City
[PacNW 2025] Farthest City
Problem Description
The State of Confusion contains cities, numbered through , and bidirectional roads. Road connects cities and and has length miles.
All cities are connected. No road connects a city to itself, and there is at most one road between any pair of cities. The distance between two cities is the length of the shortest path connecting them.
For every city, find the distance to the city farthest from it.
Input Format
The first line contains an integer (), the number of cities.
Each of the next lines contains three integers , , and (), describing one road.
Output Format
Output integers on one line. The th integer is the distance from city to its farthest city.
4
1 2 1
2 3 2
3 4 3
4 1 4
4 5 3 5