A mathematical set is a collection of distinct elements (integers). When you merge two sets, all the elements in each set are in the new set. Since each element is distinct, duplicate elements are turned into a single element.
A magical set is like a mathematical set, but with a magical merge. Instead of combining duplicate elements into a single element, a magical set, when merged, gets rid of both duplicates.
For example, sets
Create a program to simulate the merging of a number of magical sets. You may have to merge more than 2 magical sets together.
Input Specification
The first line contains two integers,
The next
The next
Note: you will have to use fast input methods.
Constraints
Subtask 1 [5%]
Subtask 2 [5%]
Subtask 3 [90%]
Output Specification
Sample Input
3 3
4 1 5 6 10
3 2 5 6
3 4 3 7
2 1 2
1 2
3 1 2 3
Sample Output
3 1 2 10
3 2 5 6
6 1 2 3 4 7 10
Explanation for Sample Output
The first merge was explained above. Only one set participates in the second merge query, so the result is identical to the second magical set. All three magical sets are merged. Since the merge is commutative, we can merge the third set with the result of the first merge to get
Comments
What do we output if the merged magical set is empty?
r3mark is correct. It still follows the same format: size, followed by (no) elements.
Just "0" I think.