#P3852. [TJOI2007] 小朋友
[TJOI2007] 小朋友
Description
Explanation of the conflict constraint:
If we regard any two conflicting children as two adjacent vertices in an undirected graph, the testdata guarantees that the graph formed by the conflicting pairs contains no cycle with more than 3 vertices. (Figure 1 satisfies the requirement, while Figure 2 does not.)

Input Format
The first line contains two integers and separated by a space, indicating there are children and pairs of conflicts. Each of the next lines contains two integers and (separated by a space), meaning that child and child have a conflict. (Children are numbered starting from .)
Output Format
Output one line containing a single integer — the maximum number of children the teacher can select to play the game.
5 6
1 2
3 2
1 3
3 5
3 4
4 5
2
Hint
There are 6 children. The conflicts contain a cycle and another cycle . Therefore, you can select exactly one child from each of these two cycles, and child cannot be selected.
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- All of the testdata satisfy the conflict constraint described in the problem.
Translated by ChatGPT 5
京公网安备 11011102002149号