#abc223g. G - Vertex Deletion
G - Vertex Deletion
Score : points
问题描述
给定一棵包含 个顶点的树。顶点编号为 ,第 条边 连接顶点 和顶点 。
找出满足以下条件的整数 的数量 。
- 从树中删除顶点 及其所有相关边后得到的图形的最大匹配的大小等于原树的最大匹配的大小。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a tree with vertices. The vertices are numbered , and the -th edge connects Vertex and Vertex .
Find the number of integers that satisfy the following condition.
- The size of the maximum matching of the graph obtained by deleting Vertex and all incident edges from the tree is equal to the size of the maximum matching of the original tree.
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 2
2 3
Sample Output 1
2
The size of the maximum matching of the original tree is .
The size of the maximum matching of the graph obtained by deleting Vertex and all incident edges from the tree is .
The size of the maximum matching of the graph obtained by deleting Vertex and all incident edges from the tree is .
The size of the maximum matching of the graph obtained by deleting Vertex and all incident edges from the tree is .
Thus, two integers satisfy the condition, so we should print .
Sample Input 2
2
1 2
Sample Output 2
0
Sample Input 3
6
2 5
3 5
1 4
4 5
4 6
Sample Output 3
4
update @ 2024/3/10 09:50:08