#P15978. [PA 2026] 研讨会 / Konferencja
[PA 2026] 研讨会 / Konferencja
Problem Description
A grand academic conference is held in Bajtocja and lasts for days. Each day, several talks are held simultaneously (at the same time). Also, some talks are continuations of talks from the previous day.
Each participant can attend at most one talk per day. Moreover, if talk is a continuation of talk , then a participant can attend talk only if they attended talk the day before. A talk can be a continuation of at most one talk from the previous day, but multiple talks may be continuations of the same talk (their participants split into several groups on the next day, and some people may not attend any continuation talk).
The King of Bajtocja wants to know exactly what happens at every talk, so he decides to send his trusted staff to attend the talks. Help him determine the minimum number of staff members that must be sent so that every talk has at least one staff member attending.
Input Format
The first line of input contains two positive integers and (), representing the number of days of the conference and the number of talks held on the first day (since it is the first day, no talk can be a continuation of an earlier talk).
Next, if , then for , line contains the description of day . The line starts with a positive integer (), the number of talks held on day , followed by integers (). means that the -th talk on day is not a continuation of any earlier talk; if , then the -th talk on day is a continuation of the -th talk on day .
The talks on each day are numbered from to . The total number of talks, i.e., the sum of all , does not exceed .
Output Format
Output one line containing one integer, the answer.
4 3
3 1 1 1
4 0 0 2 0
2 3 3
6
Hint
Explanation of the sample: We send six staff members to the talks, call them A, B, C, D, E, and F. On the first day, send A, B, C, and D to attend the first talk, E to attend the second talk, and F to attend the third talk.
On the second day, E and F stay at home (there is no talk they can attend), A and B attend the second talk, and C and D attend the first and the third talks, respectively.
On the third day, A and B attend the third talk; for each of the other talks, we send one of the remaining staff members.
On the last day, A and B attend the first and the second talks, respectively.
It can be verified that five staff members cannot cover all talks.
Translated by ChatGPT 5