Educational Codeforces Round 9


A. Grandma Laura and Apples
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 10
half
halfplus
Output
15
Input
3 10
halfplus
halfplus
halfplus
Output
55
----------------------------------------------------------------------------------------------------
B. Alice, Bob, Two Teams
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
ABABA
Output
11
Input
5
1 2 3 4 5
AAAAA
Output
15
Input
1
1
B
Output
1
----------------------------------------------------------------------------------------------------
C. The Smallest String Concatenation
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abba
abacaba
bcd
er
Output
abacabaabbabcder
Input
5
x
xx
xxa
xxaa
xxaaa
Output
xxaaaxxaaxxaxxx
Input
3
c
cb
cba
Output
cbacbc
----------------------------------------------------------------------------------------------------
D. Longest Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 8
6 2 9 2 7 2 3
Output
6 5
1 2 4 6 7
Input
6 4
2 2 2 3 3 3
Output
2 3
1 2 3
----------------------------------------------------------------------------------------------------
E. Thief in a Shop
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2 3
Output
2 3 4 5 6
Input
5 5
1 1 1 1 1
Output
5
Input
3 3
3 5 11
Output
9 11 13 15 17 19 21 25 27 33
----------------------------------------------------------------------------------------------------
F. Magic Matrix
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
0 1 2
1 0 2
2 2 0
Output
MAGIC
Input
2
0 1
2 3
Output
NOT MAGIC
Input
4
0 1 2 3
1 0 3 4
2 3 0 5
3 4 5 0
Output
NOT MAGIC
----------------------------------------------------------------------------------------------------
