P29378 [洛谷] [COCI2014-2015#1] MAFIJA
提高-
题目描述

Problem Description

There are $n$ people, some of whom are civilians and some are criminals.

The civilians want to identify all the criminals, so each of the $n$ people accuses one person of being a criminal.

If a person is a civilian, they will accuse randomly, otherwise, they will accuse a civilian.

Determine the maximum number of criminals.

Input Format

The first line contains an integer $n$.

The next $n$ lines each contain an integer $k$, where the $i$-th line indicates that the $i$-th person accuses the $k$-th person.

Output Format

Output a single integer, which is the maximum number of criminals.

Sample Input and Output

Sample Input #1

3
2
1
1

Sample Output #1

2

Sample Input #2

3
2
3
1

Sample Output #2

1

Sample Input #3

7
3
3
4
5
6
4
4

Sample Output #3

4

Notes

Sample Explanation

Sample Input and Output 1 Explanation

The criminals can be the 2nd and 3rd persons.

Sample Input and Output 2 Explanation

The criminal could be any one of the people, but only one person can be the criminal because having more than one criminal would result in a criminal accusing another criminal.

Data Range and Constraints

  • For 40 points, $n \le 15$.
  • For 80 points, $n \le 2 \times 10^4$.
  • For 100% of the points, $1 \le n \le 5 \times 10^5$, $1 \le k \le n$.

Notes

This problem is worth a total of 120 points.

This problem is translated from the Croatian Open Competition in Informatics 2014/2015 Contest #1 T4 MAFIJA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 1 1
样例输出
2