#P9421. [蓝桥杯 2023 国 B] 班级活动
[蓝桥杯 2023 国 B] 班级活动
Problem Description
Xiaoming’s teacher is preparing to organize a class activity. There are students in the class ( 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 as their id. The id of the -th student is .
The teacher hopes to change the ids of some students so that for any student , there exists exactly one other student whose id is the same as theirs (). How many students’ ids does the teacher need to change at minimum?
Input Format
The input consists of lines.
The first line contains a positive integer .
The second line contains integers separated by spaces.
Output Format
The output consists of line, an integer.
4
1 2 2 3
1
Hint
Sample Explanation
You only need to change to , or change to .
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
The 14th Lanqiao Cup Software Contest Finals, C/C++ University Group B, Problem C.
Translated by ChatGPT 5