#P9421. [蓝桥杯 2023 国 B] 班级活动

[蓝桥杯 2023 国 B] 班级活动

Problem Description

Xiaoming’s teacher is preparing to organize a class activity. There are nn students in the class (nn is even). The teacher wants to split all students into groups, with two students per group. To be fair, the teacher randomly assigns each student a positive integer within nn as their id. The id of the ii-th student is aia_i.

The teacher hopes to change the ids of some students so that for any student ii, there exists exactly one other student jj whose id is the same as theirs (ai=aja_i = a_j). How many students’ ids does the teacher need to change at minimum?

Input Format

The input consists of 22 lines.

The first line contains a positive integer nn.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n separated by spaces.

Output Format

The output consists of 11 line, an integer.

4
1 2 2 3
1

Hint

Sample Explanation

You only need to change a1a_1 to 33, or change a4a_4 to 11.

Constraints

  • For 20%20\% of the testdata, it is guaranteed that n103n \le 10^3.
  • For 100%100\% of the testdata, it is guaranteed that n105n \le 10^5.

The 14th Lanqiao Cup Software Contest Finals, C/C++ University Group B, Problem C.

Translated by ChatGPT 5