#C4144. Minimum Challenge Scheduling

    ID: 47650 Type: Default 1000ms 256MiB

Minimum Challenge Scheduling

Minimum Challenge Scheduling

You are given an integer \(n\) representing the number of participants and \(n\) lists of available time slots for each participant. A challenge can only be held at a specific time slot. The objective is to schedule a minimal number of challenges so that every participant can attend at least one challenge. Formally, you need to select a set \(S\) of time slots with minimum cardinality such that for every participant \(i\) with available time slots \(A_i\), the intersection \(A_i \cap S \neq \emptyset\).

For example, if \(n=3\) and the available time slots are:

  • Participant 1: {1, 2}
  • Participant 2: {2, 3, 4}
  • Participant 3: {1, 3}

Then one optimal solution is to schedule challenges at time slots 1 and 2, so the answer is 2.

inputFormat

The first line contains an integer \(n\), the number of participants. Each of the next \(n\) lines begins with an integer \(k\), indicating the number of available time slots for that participant, followed by \(k\) distinct integers representing the available time slots.

outputFormat

Output a single integer representing the minimum number of challenges required so that every participant can attend at least one challenge.

## sample
3
2 1 2
3 2 3 4
2 1 3
2