#K8231. Maximum Water Flow

    ID: 35947 Type: Default 1000ms 256MiB

Maximum Water Flow

Maximum Water Flow

You are given a network of towns connected by bidirectional roads, where each road has a fixed water capacity. Town 1 is the capital, and water is delivered from the capital to all other towns. For each town (from town 2 to town n), determine the maximum possible water flow that can be delivered along the unique path from the capital. The water flow to a town is limited by the smallest capacity (bottleneck) on the path from the capital to that town.

In other words, for each town i (i = 2, 3, ..., n), if the unique path from town 1 to town i has roads with capacities \(c_1, c_2, \ldots, c_k\), then the maximum water flow to town i is given by:

[ \text{flow}(i) = \min{ c_1, c_2, \ldots, c_k } ]

If there is only the capital, output nothing.

inputFormat

The input is read from stdin and has the following format:

  1. An integer n (\(1 \leq n \leq 10^5\)) denoting the number of towns. If n = 1, then no further input is provided.
  2. For n > 1, exactly n - 1 lines follow. Each line contains three integers u, v, and c, representing a bidirectional road between towns u and v with water capacity c (\(1 \leq c \leq 10^9\)).

outputFormat

Print the maximum water flow values for towns 2 to n on a single line, separated by spaces. If there is no town other than the capital, print nothing.

## sample
5
1 2 10
1 3 5
2 4 7
3 5 4
10 5 7 4