#P3420. [POI 2005] SKA-Piggy Banks
[POI 2005] SKA-Piggy Banks
Description
Byteazar the Dragon has 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 (), representing the number of piggy banks owned by Byteazar the Dragon.
The piggy banks (including their corresponding keys) are numbered from to .
Then there are lines: the -th line contains an integer , indicating that the key for the -th piggy bank is placed in the -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
京公网安备 11011102002149号