Educational Codeforces Round 136 (Rated for Div. 2)


A. Immobile Knight
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 7
8 8
3 3
Output
1 7
7 2
2 2
----------------------------------------------------------------------------------------------------
B. Array Recovery
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 0 2 5
3
2 6 3
5
0 0 0 0 0
Output
1 1 3 8
-1
0 0 0 0 0
----------------------------------------------------------------------------------------------------
C. Card Game
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2
4
6
8
60
Output
1 0 1
3 2 1
12 7 1
42 27 1
341102826 248150916 1
----------------------------------------------------------------------------------------------------
D. Reset K Edges
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2
01
11
Output
2
Input
2
01
01
Output
2
Input
4
0101
1011
Output
4
Input
4
0000
0000
Output
0
Input
5
00011
10101
Output
4
Input
6
011111
111111
Output
8
Input
10
0101001010
1010100110
Output
6
----------------------------------------------------------------------------------------------------
F. Keyboard Design
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
7 abacaba
10 cba
4 db
Output
hjkildbacefg
Input
1
100 abca
Output
abcdefghijkl
----------------------------------------------------------------------------------------------------
