H. [NERC 2020 Online] Miser

    远端评测题 2000ms 512MiB

[NERC 2020 Online] Miser

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

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.

Input Format

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 Format

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

ICPC欢乐赛

未参加
状态
已结束
规则
XCPC
题目
8
开始于
2026-2-7 8:30
结束于
2026-2-7 12:30
持续时间
4 小时
主持人
参赛人数
22