Logo
(追記) (追記ここまで)

10542번 - MAFIJA 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB73018114331.637%

문제

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 los 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 < N < 500 000), the number of players. The players are labeled with integers from 1 to N.

The Kth line of input, out of the following N lines, contains the label of the player accused by the 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

예제 출력 1

2

예제 입력 2

3
2
3
1

예제 출력 2

1

예제 입력 3

7
3
3
4
5
6
4
4

예제 출력 3

4

힌트

Clarification of the first sample test: The mobster can be player 2 and 3.

Clarification of the second sample test: The mobster can be any player, but there cannot be more of them because that would mean that one of them accused the other.

출처

Contest > Croatian Open Competition in Informatics > COCI 2014/2015 > Contest #1 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /