포럼
문제 COCI00313

Mafija

설명

Mafia is a social game played frequently by high school competitors in informatics on summer and winter camps and national competitions, usually very late at night, drinking various fruit sodas. This game is not about winning, it's about loss taking part, like in competitions.

To solve this task, you don't need to know the rules of Mafia: all you need to know is that some of the players are "mobsters" and the rest are "civilians". The mobsters know who is who, but the civilians don't. The civilians are trying to figure out who the mobsters are during the game.

In the current round of the game, out of \(N\) surviving players so far, each one has accused exactly one other player saying that he is the mobster. The civilians were only guessing and the mobsters have accused civilians, pretending to know nothing.

Not knowing who the mobsters are, but knowing who accused whom, determine the maximum possible number of mobsters among these players!

제약
입력 형식

The first line of input contains the integer \(N\) \((2 \le N \le 500\,000)\), the number of players. The players are labeled with integers from \(1\) to \(N\).
The \(K^{th}\) line of input, out of the following \(N\) lines, contains the label of the player accused by player \(K\). (No player can accuse themselves.)

출력 형식

The first and only line of output must contain the maximum possible number of mobsters.

예제 1
입력
3
2
1
1
출력
2
예제 2
입력
3
2
3
1
출력
1
예제 3
입력
7
3
3
4
5
6
4
4
출력
4
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2014/2015 Contest 1

평가 및 의견

Mafija

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Mafija

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8