Pro.ID10245 TitleMarbles on a tree Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10245 AC0 Submit0 Ratio- 时间&空间限制描述n boxes are placed on the vertices of a rooted tree, which are numbered from 1 to n, 1 ≤ n ≤ 10000. Each box is either empty or contains a number of marbles; the total number of marbles is n. 输入The input contains a number of cases. Each case starts with the number n followed by n lines. Each line contains at least three numbers which are: v the number of a vertex, followed by the number of marbles originally placed at vertex v followed by a number d which is the number of children of v, followed by d numbers giving the identities of the children of v. 输出Description n boxes are placed on the vertices of a rooted tree, which are numbered from 1 to n, 1 ≤ n ≤ 10000. Each box is either empty or contains a number of marbles; the total number of marbles is n. Input The input contains a number of cases. Each case starts with the number n followed by n lines. Each line contains at least three numbers which are: v the number of a vertex, followed by the number of marbles originally placed at vertex v followed by a number d which is the number of children of v, followed by d numbers giving the identities of the children of v. Output For each case in the input, output the smallest number of moves of marbles resulting in one marble at each vertex of the tree. Sample Input 9 Sample Output 7 Source 样例输入9 样例输出7 作者 |