Logo
(追記) (追記ここまで)

11429번 - Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB64474178.846%

문제

A weighted tree is a tree where each edge is labeled with a number representing the edge's length. All lengths are positive. For each node, you have to find the maximum possible distance to any other node in the tree.

입력

The input file contains the description of the tree. The first line of the input file contains one integer N, 2<=N<=50000. Each of the following (N-1) lines contains the description of the tree’s edges. Each edge is described by three positive integers. The first two integers are the labels of the nodes connected by this edge, ranging from 1 to N, the third number – the length of the edge. The total length of all edges does not exceed 231 -1. It is guaranteed that the file contains a correct description of the tree.

출력

The output consists of exactly N lines: the k-th line contains the distance from node k (k=1..N ) to the most distant node.

제한

예제 입력 1

6
1 5 3
2 6 3
6 1 1
1 3 5
4 6 4

예제 출력 1

5
9
10
10
8
6

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2012 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /