Codeforces Round 670 (Div. 2)


A. Subset Mex
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
6
0 2 1 5 0 1
3
0 1 2
4
0 2 0 1
6
1 2 3 4 5 6
Output
5
3
4
0
----------------------------------------------------------------------------------------------------
B. Maximum Product
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
Output
-120
12
0
945
----------------------------------------------------------------------------------------------------
C. Link Cut Centroids
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
5
1 2
1 3
2 4
2 5
6
1 2
1 3
1 4
2 5
2 6
Output
1 2
1 2
1 3
2 3
----------------------------------------------------------------------------------------------------
D. Three Sequences
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2 -1 7 3
2
2 4 -3
3 4 2
Output
5
5
6
Input
6
-9 -10 -9 -6 -5 4
3
2 6 -9
1 2 -10
4 6 -3
Output
3
3
3
1
Input
1
0
2
1 1 -1
1 1 -1
Output
0
0
-1
----------------------------------------------------------------------------------------------------
E. Deleting Numbers
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
2
4
0
Output
B 4
A 2
A 8
C 4
----------------------------------------------------------------------------------------------------
