#P1623. [CEOI 2007] 树的匹配 Treasury

    ID: 610 远端评测题 500ms 32MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp高精度树形结构2007CEOI

[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 NN, the number of nodes.

Each of the next NN lines describes one node: the first integer is the ID of the node being described, then an integer mm indicating that this node has mm children, followed by mm integers, the IDs of its mm 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: 1N1031\leq N\leq 10^3. For 40% of the testdata, the answer does not exceed 10810^8.

Translated by ChatGPT 5