#P2835. 刻录光盘
刻录光盘
Description
The organizing committee handed this problem to LHC. After analyzing the campers’ locations, LHC found that some campers are from the same city. In fact, they only need one disc, because once one person gets the disc, others can bring a USB drive and copy the materials.
However, after investigation, LHC discovered that, for various reasons, some campers are not very cooperative: they are willing to let certain people copy materials from them, but unwilling to let others do so. This goes against the team spirit promoted by JSOI.
Now suppose there are campers , numbered . LHC gave everyone a survey form to fill in the people they are willing to let copy materials from them. Of course, if A is willing to copy to B, and B is willing to copy to C, then once A obtains the materials, both B and C will obtain them.
Please write a program that, based on the returned survey forms, helps LHC compute the minimum number of CDs the organizing committee must burn to ensure that all campers can get the summer camp materials after going home.
Input Format
First is a number indicating there are campers. The next lines respectively indicate which other campers each camper is willing to copy the materials to. Specifically, the -th line of the input indicates the IDs of the campers to whom the -th camper is willing to copy, ending with . If a camper is unwilling to copy to anyone, the corresponding line contains only . Numbers on a line are separated by a single space.
Output Format
A single positive integer, indicating the minimum number of CDs that must be burned.
5
2 3 4 0
4 5 0
0
0
1 0
1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号