Codeforces Round 758 (Div.1 + Div. 2)


A. Find Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
7
Output
1
2 3
111 1111 11111 111111 1111111 11111111 111111111
----------------------------------------------------------------------------------------------------
B. Build the Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 1 1
6 1 2
6 4 0
Output
1 3 2 4
4 2 3 1 5 6
-1
----------------------------------------------------------------------------------------------------
C. Game Master
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 2 3 4
1 2 3 4
4
11 12 20 21
44 22 11 30
1
1000000000
1000000000
Output
0001
1111
1
----------------------------------------------------------------------------------------------------
D. Dominoes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
?W
Output
1
Input
2
??
W?
Output
2
Input
4
BB
??
W?
??
Output
10
----------------------------------------------------------------------------------------------------
E. The Cells on the Paper
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
2 3 1
4 1 2
2 1 3
3 4 1
5 3 2
4 4 3
2 4 1
5 2 2
3 5 3
Output
6
Input
3
1 1 1
2 2 2
3 3 3
Output
3
----------------------------------------------------------------------------------------------------
F. MEX counting
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 0
0 0 0 0
Output
256
Input
4 1
0 0 0 0
Output
431
Input
4 1
0 0 1 1
Output
509
Input
5 2
0 0 2 2 0
Output
6546
Input
3 2
-2 0 4
Output
11
----------------------------------------------------------------------------------------------------
G. Alphabetic Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5 3
1 2 a
aab
abab
aaa
b
a
2 1 1 5
1 2 1 3
2 1 3 5
Output
8
7
4
Input
9 5 6
1 2 a
2 7 c
1 3 b
3 4 b
4 6 b
3 5 a
5 8 b
5 9 c
ababa
cabbb
bac
bbbac
abacaba
2 7 1 4
2 5 1 5
6 3 4 4
6 9 4 5
5 7 3 5
5 3 1 5
Output
3
4
2
1
1
10
----------------------------------------------------------------------------------------------------
