atcoder#ARC156F. [ARC156F] Make Same Set
[ARC156F] Make Same Set
Score : points
Problem Statement
You are given three integer sequences of length : $A=(A_1,A_2,\dots,A_N),B=(B_1,B_2,\dots,B_N),C=(C_1,C_2,\dots,C_N)$.
Find one set of integers that satisfies the following conditions.
- It can be obtained as follows: start with an empty set, and for each in this order, add or to the set.
- It can be obtained as follows: start with an empty set, and for each in this order, add or to the set.
- It has the maximum number of elements among the sets that satisfy the two conditions above.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print , the number of elements in the set of integers satisfying the conditions, and , the elements of the set, in the following format:
If multiple sets satisfy the conditions, you may print any of them.
3
1 1 1
2 3 4
5 4 2
3
4 1 2
For the set , we have the following.
- The first condition is satisfied because you can add to an empty set to obtain this set.
- The second condition is satisfied because you can add to an empty set to obtain this set.
Clearly, any set satisfying these conditions has at most elements, so this set also satisfies the third condition.
15
1 1 15 11 13 7 7 1 6 1 5 7 4 9 8
11 30 1 18 16 15 19 17 3 27 22 7 21 29 9
24 14 23 17 18 16 9 12 10 5 26 29 20 19 11
12
7 9 11 17 19 1 15 4 5 6 29 13