#C6744. Determine the Student with Maximum Unique Problems Solved

    ID: 50538 Type: Default 1000ms 256MiB

Determine the Student with Maximum Unique Problems Solved

Determine the Student with Maximum Unique Problems Solved

You are given data about M students, where each student is identified by their unique ID and has solved a list of problems (possibly with duplicates). Your task is to determine the student who solved the maximum number of unique problems. In case of a tie (i.e. multiple students solved the same number of unique problems), the student with the smaller ID wins.

The uniqueness is defined by counting each distinct problem only once. Formally, if a student has solved problems represented by the set \( S \), then the score for that student is \(|S|\). If two students have the same score, then the one with the lower student ID is the winner.

inputFormat

The input is given via stdin in the following format:

  • The first line contains an integer M representing the number of students.
  • The following M lines each describe one student. Each line starts with the student's ID, followed by an integer K indicating the number of problems solved, and then K integers representing the IDs of the problems solved (problems may appear more than once).

For example:

3
101 5 1 2 3 1 4
102 3 2 3 4
103 4 1 2 1 2

outputFormat

Output the ID of the student who solved the maximum number of unique problems. The output should be printed to stdout as a single integer.

## sample
3
101 5 1 2 3 1 4
102 3 2 3 4
103 4 1 2 1 2
101