| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 2048 MB | 12 | 7 | 4 | 50.000% |
There are $n$ cities in the State of Confusion, numbered from 1ドル$ to $n$. There are $n$ bidirectional roads that connect the cities. The $i$th road connects cities $a_i$ and $b_i,ドル and is $d_i$ miles long.
All $n$ cities are connected. In other words, regardless of which city you start from, it is always possible to reach any other city using the given roads. In addition, no road connects a city to itself, and there is at most one road between any pair of cities.
You are interested in holding a statewide event in one of the cities. One of the important factors to consider is how far away the rest of the cities are from where the event will be held. The distance between two cities is the length of the shortest path that connects them.
Given the information about all roads, find the distance to the farthest city from every city in the state.
The first line of the input contains a single integer $n$ (3ドル \le n \le 3 \cdot 10^5$), representing the number of cities in the state. Each of the next $n$ lines contains three integers $a_i,ドル $b_i,ドル $d_i$ (1ドル \le d_i \le 10^7$), describing one of the roads.
Output $n$ integers on a single line, where the $i$th number denotes the distance of the city that is the farthest from city $i$.
4 1 2 1 2 3 2 3 4 3 4 1 4
4 5 3 5
ICPC > Regionals > North America > Pacific Northwest Regional > 2025 ICPC Pacific Northwest Regional > Division 1 D번