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

7960번 - Piggy Banks 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 128 MB34222165.625%

문제

Byteazar the Dragon has N piggy banks. Each piggy bank can either be opened with its corresponding key or smashed. Byteazar has put the keys in some of the piggy banks - he remembers which key has been placed in which piggy bank. Byteazar intends to buy a car and needs to gain access to all of the piggy banks. However, he wants to destroy as few of them as possible. Help Byteazar to determine how many piggy banks have to be smashed.

Write a programme which:

  • reads from the standard input the number of piggy banks and the deployment of their corresponding keys,
  • finds the minimal number of piggy banks to be smashed in order to gain access to all of them,
  • writes the outcome to the standard output.

입력

The first line of the standard input contains a single integer N (1 ≤ N ≤ 1,000,000) - this is the number of piggy banks owned by the dragon. The piggy banks (as well as their corresponding keys) are numbered from 1 to N. Next, there are N lines: the (i+1)’st line contains a single integer - the number of the piggy bank in which the i’th key has been placed.

출력

The first and only line of the standard output should contain a single integer - the minimal number of piggy banks to be smashed in order to gain access to all of the piggy banks.

제한

예제 입력 1

4
2
1
2
4

예제 출력 1

2

힌트

In the foregoing example piggy banks 1 and 4 have to be smashed.

출처

Olympiad > Polish Olympiad in Informatics > POI 2004/2005 > Stage 1 4번

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

출처

대학교 대회

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

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