#Q158. 「一本通 5.2 例 4」战略游戏
「一本通 5.2 例 4」战略游戏
Description
Bob enjoys playing computer games, especially strategy games. However, he often struggles to find quick ways to beat them. Now he has a problem.
He owns an ancient castle where the roads form a tree structure. He wants to place the minimum number of soldiers on the nodes of this tree so that these soldiers can watch over all the roads.
Note: When a soldier is placed on a node, all edges connected to that node can be observed.
Please write a program that, given a tree, helps Bob calculate the minimum number of soldiers he needs to place.
Input Format
The input data represents a tree, described as follows.
The first line contains a number , representing the number of nodes in the tree.
The second to the -th lines each describe a node's information, in the order of the node's index , a numerical value , where indicates that there are edges connected to node , followed by numbers representing the indices of the connected nodes .
For a tree with nodes, the node indices range from to , and each edge appears only once in the input file.
Output Format
The output contains only one number, which is the minimum number of soldiers required.
Sample 1
4
0 1 1
1 2 2 3
2 0
3 0
1
Data Range and Hint
For of the data, .