Educational Codeforces Round 107 (Rated for Div. 2)


A. Review Site
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
3
1 2 3
5
1 1 1 1 1
3
3 3 2
Output
0
2
5
2
----------------------------------------------------------------------------------------------------
B. GCD Length
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3 1
2 2 2
6 6 2
1 1 1
Output
11 492
13 26
140133 160776
1 1
----------------------------------------------------------------------------------------------------
C. Yet Another Card Deck
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 5
2 1 1 4 3 3 1
3 2 1 1 4
Output
5 2 3 1 5 
----------------------------------------------------------------------------------------------------
D. Min Cost String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 4
Output
aabacadbb
Input
5 1
Output
aaaaa
Input
10 26
Output
codeforces
----------------------------------------------------------------------------------------------------
E. Colorings and Dominoes
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
**oo
oo*o
**oo
Output
144
Input
3 4
**oo
oo**
**oo
Output
48
Input
2 2
oo
o*
Output
4
Input
1 4
oooo
Output
9
----------------------------------------------------------------------------------------------------
F. Chainword
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
ababa
ab
a
Output
11
Input
2 4
ab
cd
Output
4
Input
5 100
a
aa
aaa
aaaa
aaaaa
Output
142528942
----------------------------------------------------------------------------------------------------
G. Chips on a Board
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8 10
1 3 3 7 4 2 6 9
7
2 3
1 3
1 4
1 10
5 10
8 10
9 10
Output
BAAAAAB
----------------------------------------------------------------------------------------------------
