#P2071. 座位安排

座位安排

Description

There are NN rows of seats on the bus, and 2N2N people heading to the provincial contest. Each row can seat two people, and each person has two preferred rows they are willing to sit in. What is the maximum number of people who can be seated in one of their preferred rows?

Input Format

  • The first line contains a positive integer NN.
  • From the second line to line 2N+12N+1, for i=1,2,,2Ni = 1, 2, \ldots, 2N, each line contains two positive integers Si,1,Si,2S_{i, 1}, S_{i, 2}, representing the rows the ii-th person wants to sit in.

Output Format

A non-negative integer, the maximum number of satisfied people.

4
1 2
1 3
1 2
1 3
1 3
2 4
1 3
2 3

7

Hint

Constraints:

  • For 10% of the testdata, N10N \le 10.
  • For 30% of the testdata, N50N \le 50.
  • For 60% of the testdata, N200N \le 200.
  • For 100% of the testdata, N2000N \le 2000.

Translated by ChatGPT 5