Educational Codeforces Round 160 (Rated for Div. 2)


A. Rating Increase
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
20002001
391125
200200
2001000
12
Output
2000 2001
39 1125
-1
200 1000
1 2
----------------------------------------------------------------------------------------------------
B. Swap and Delete
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0
011
0101110001
111100
Output
1
1
0
4
----------------------------------------------------------------------------------------------------
C. Game with Multiset
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 0
1 0
1 0
2 3
2 4
Output
YES
NO
Input
7
1 0
1 1
1 2
1 10
2 4
2 6
2 7
Output
YES
YES
YES
----------------------------------------------------------------------------------------------------
D. Array Collapse
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
2 1
4
2 4 1 3
5
10 2 6 3 4
Output
2
6
12
----------------------------------------------------------------------------------------------------
E. Matrix Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
0 0 0
0 0 0
0 0 0
1 1 1
1 1 1
Output
3
Input
3 3
1 1 1
1 1 1
1 1 1
3 2 1
1 2 3
Output
3
Input
2 2
0 0
0 0
1 2
0 1
Output
-1
----------------------------------------------------------------------------------------------------
F. Palindromic Problem
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
aabaa
Output
15
aaaaa
Input
5
aaaaa
Output
15
aaaaa
Input
4
awoo
Output
7
aooo
----------------------------------------------------------------------------------------------------
