#P3420. [POI 2005] SKA-Piggy Banks

    ID: 2475 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2005并查集POI连通块概率论,统计

[POI 2005] SKA-Piggy Banks

Description

Byteazar the Dragon has NN piggy banks. Each piggy bank can be opened with its corresponding key or smashed. Byteazar has placed the keys into some piggy banks. Given, for each key, which piggy bank it is in, Byteazar wants to buy a car and needs to open all piggy banks. However, he wants to destroy as few piggy banks as possible. Help Byteazar decide the minimum number of piggy banks that must be smashed.

Input Format

The first line contains an integer NN (1N10000001\le N\le 1000000), representing the number of piggy banks owned by Byteazar the Dragon.

The piggy banks (including their corresponding keys) are numbered from 11 to NN.

Then there are NN lines: the (i+1)(i+1)-th line contains an integer xx, indicating that the key for the ii-th piggy bank is placed in the xx-th piggy bank.

Output Format

A single line containing an integer, representing the minimum number of piggy banks that must be smashed in order to be able to open all piggy banks.

4
2
1
2
4
2

Hint

Translated by ChatGPT 5