#K40722. Maximum Unique Signals
Maximum Unique Signals
Maximum Unique Signals
You are given a number of test cases. In each test case, you are provided with several sets of signals. Each set begins with an integer m denoting the number of signals in that set followed by m space‐separated integers representing the signal values.
Your task is to determine the total number of unique signals across all sets for each test case.
Input Format: The first line contains an integer T denoting the number of test cases. For each test case, the first line contains an integer n denoting the number of sets. This is followed by n lines, each starting with an integer m (the count of signals in that set) followed by m space separated integers.
Output Format: For each test case, output a single line containing the number of unique signals found across all the given sets.
The solution should read input from stdin
and print the output to stdout
.
inputFormat
The input is read from stdin
and follows this format:
T n m1 a1 a2 ... a_m1 m2 b1 b2 ... b_m2 ... mn c1 c2 ... c_mn ... (repeated for each test case)
Where:
T
is the number of test cases.- For each test case,
n
is the number of signal sets. - For each set, the first integer
m
indicates the number of signals in that set, followed bym
integers representing the signals.
outputFormat
For each test case, output a single line with an integer representing the total count of unique signals collected from all the sets in that test case. The output is written to stdout
.
2
2
3 1 2 3
2 2 3
3 2 1 2
3 2 3 4
2 3 5
3
5
</p>