#P12862. [NERC 2020 Online] Miser

[NERC 2020 Online] Miser

题目描述

In some non-classical University, there is going to be an opening ceremony of the cafeteria in nn days. In front of the closed cafeteria, there is a sign with a number --- how many days are left before the opening.

For each day out of these nn, the director of the cafeteria knows all the people who are coming to the University and are going to see the sign. The director has to choose a sign with a number each day, such that each person who is coming to the University sees that the number on the sign is decreasing. The director is a typical miser\emph{miser} who spends as little money as possible and wants to order the minimum possible number of different signs. Your task is to help the director find this number.

Consider the first test case: person 11 comes on days 11, 22 and 55, and person 22 comes on days 22, 33 and 44. The director can order just four signs with numbers 11, 22, 33 and 44, to put a sign with 11 on days 55 and 44, a sign with 22 on day 33, a sign with 33 on day 22, and a sign with 44 on day 11. Thus, person 11 will see the signs 44, 22, and 11 and person 22 will see the signs 33, 22, and 11.

输入格式

The first line of the input contains an integer nn --- the total number of days before the opening of the~cafeteria. The next nn lines contain the description of each day. The description starts with the positive integer kk --- the number of people that come to the University this day. This integer is followed by kk distinct integers --- the identifiers of the people that come.

The sum of all kk over all days does not exceed 10510^5. Identifiers of people are positive and do not exceed 10510^5.

输出格式

Output one integer --- the minimum possible number of different signs that have to be ordered.

5
1 1
2 1 2
1 2
1 2
1 1
4
5
1 1
1 1
1 1
1 1
1 1
5