#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 MM 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 NN and MM separated by a space, indicating there are NN children and MM pairs of conflicts. Each of the next MM lines contains two integers aa and bb (separated by a space), meaning that child aa and child bb have a conflict. (Children are numbered starting from 11.)

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 1231 - 2 - 3 and another cycle 3453 - 4 - 5. Therefore, you can select exactly one child from each of these two cycles, and child 33 cannot be selected.

Constraints:

  • For 20%20\% of the testdata, 1N201 \le N \le 20.
  • For 40%40\% of the testdata, 1N501 \le N \le 50.
  • For 100%100\% of the testdata, 1N2001 \le N \le 200.
  • All 100%100\% of the testdata satisfy the conflict constraint described in the problem.

Translated by ChatGPT 5