logo AlgoBeat OnlineJudge
登录 注册

#217691. [PacNW 2025] Farthest City

内存限制:2048 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

输入格式

The first line contains an integer (), the number of cities.

Each of the next lines contains three integers , , and (), describing one road.

输出格式

Output integers on one line. The th integer is the distance from city to its farthest city.

样例

样例输入 1

4
1 2 1
2 3 2
3 4 3
4 1 4

样例输出 1

4 5 3 5