A. Subset Mex SOLUTION CODEFORCES

Subset Mex SOLUTION

Given a lot of numbers (it can contain equivalent components).
You need to part it into two subsets An and B (them two can contain equivalent components or be unfilled). You need to boost the estimation of mex(A)+mex(B).
Here mex of a set indicates the littlest non-negative number that doesn’t exist in the set. For instance:
mex({1,4,0,2,2,1})=3
mex({3,3,2,1,3,0,0})=4
mex(∅)=0 (mex for void set)
The set is splitted into two subsets An and B if for any number x the quantity of events of x into this set is equivalent to the aggregate of the quantity of events of x into An and the quantity of events of x into B.
Info
The info comprises of numerous experiments. The principal line contains a number t (1≤t≤100) — the quantity of experiments. The depiction of the experiments follows.
The main line of each experiment contains a number n (1≤n≤100) — the size of the set.
The second line of each testcase contains n whole numbers a1,a2,… a (0≤ai≤100) — the numbers in the set.
Yield
For each experiment, print the greatest estimation of mex(A)+mex(B).
Model
inputCopy
4
6
0 2 1 5 0 1
3
0 1 2
4
0 2 0 1
6
1 2 3 4 5 6
outputCopy
5
3
4
0
Note
In the main experiment, A={0,1,2},B={0,1,5} is a potential decision.
In the subsequent experiment, A={0,1,2},B=∅ is a potential decision.
In the third experiment, A={0,1,2},B={0} is a potential decision.
In the fourth experiment, A={1,3,5},B={2,4,6} is a potential decision.

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+