#P2016. [SEERC 2000] 战略游戏
[SEERC 2000] 战略游戏
Description
He wants to build an ancient castle, where the roads inside form an unrooted tree. He wants to place the minimum number of soldiers on the tree’s nodes so that these soldiers can watch all the roads.
Note that when a soldier is on a node, all edges incident to that node can be watched.
Please write a program that, given a tree, helps Bob compute the minimum number of soldiers he needs to place.
Input Format
The first line contains an integer , the number of nodes in the tree.
From the second line to the -th line, each line describes one node’s information in the following order: an integer , the label of this node; a natural number , meaning there are undirected edges incident to node ; followed by integers, which are the labels of the other endpoints , indicating that there is one undirected edge between and each of these nodes.
For a tree with nodes, the node labels are between and . In the input, each edge appears exactly once. It is guaranteed that the input describes a tree.
Output Format
Output a single integer, the minimum number of soldiers required.
4
0 1 1
1 2 2 3
2 0
3 0
1
Hint
Constraints
For all test points, .
Translated by ChatGPT 5
京公网安备 11011102002149号