| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Tree
Description You are given a tree with N nodes. The tree¡¯s nodes are numbered 1 through N and its edges are numbered 1 through N
− 1. Each edge is associated with a weight. Then you are to execute a
series of instructions on the tree. The instructions can be one of the
following forms: Input The input contains multiple test cases. The first line of input contains an integer t (t ¡Ü 20), the number of test cases. Then follow the test cases. Each test case is preceded by an empty line. The first nonempty line of its contains N (N ¡Ü 10,000). The next N − 1 lines each contains three integers a, b and c, describing an edge connecting nodes a and b with weight c.
The edges are numbered in the order they appear in the input. Below
them are the instructions, each sticking to the specification above. A
lines with the word ¡° Output For each ¡° Sample Input Sample Output Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2006 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator