#P1623. [CEOI 2007] 树的匹配 Treasury
[CEOI 2007] 树的匹配 Treasury
Description
Given a tree, you may match two vertices that are connected by an edge. Find the size of a maximum matching of this tree, and compute how many maximum matchings there are.
Input Format
The first line contains an integer , the number of nodes.
Each of the next lines describes one node: the first integer is the ID of the node being described, then an integer indicating that this node has children, followed by integers, the IDs of its children.
Output Format
Output two lines: the first line is the size of the maximum matching, and the second line is the number of maximum matchings.
7
1 3 2 4 7
2 1 3
4 1 6
3 0
7 1 5
5 0
6 0
3
4
Hint
Constraints: . For 40% of the testdata, the answer does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号