#P6417. [COCI 2014/2015 #1] MAFIJA
[COCI 2014/2015 #1] MAFIJA
Description
There are people. Some of them are civilians, and some of them are gangsters.
Now the civilians want to find all the gangsters, so each of the people has accused one person of being a gangster.
If a person is a civilian, they will accuse someone randomly. Otherwise, they will accuse a civilian.
Find the maximum possible number of gangsters.
Input Format
The first line contains an integer .
The next lines each contain an integer . Line means that person accused person .
Output Format
Output a single integer: the maximum possible number of gangsters.
3
2
1
1
2
3
2
3
1
1
7
3
3
4
5
6
4
4
4
Hint
Sample Explanation
Explanation for Sample Input/Output 1
The gangsters can be person and person .
Explanation for Sample Input/Output 2
The gangsters could be everyone, but then there can only be one gangster among them. If there is one more gangster, a gangster would accuse a gangster, which is not allowed.
Constraints
- For the testdata worth points, it is guaranteed that .
- For the testdata worth points, it is guaranteed that .
- For the testdata worth of the testdata, it is guaranteed that , .
Note
The total score of this problem is points.
This problem is translated from Croatian Open Competition in Informatics 2014/2015 Contest #1 T4 MAFIJA.
Translated by ChatGPT 5
京公网安备 11011102002149号