Educational Codeforces Round 162 (Rated for Div. 2)


A. Moving Chips
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
8
0 1 1 1 0 1 1 0
6
0 1 0 0 0 0
6
1 1 1 1 1 1
5
1 0 1 0 1
9
0 1 1 0 0 0 1 1 0
Output
1
0
0
2
3
----------------------------------------------------------------------------------------------------
B. Monsters Attack!
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2
1 2 3
-1 2 3
2 1
1 1
-1 1
4 10
3 4 2 5
-3 -2 1 3
5 3
2 1 3 2 5
-3 -2 3 4 5
2 1
1 2
1 2
Output
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
C. Find B
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5 4
1 2 1 4 5
1 5
4 4
3 4
1 3
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
D. Slimes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
3 2 4 2
3
1 2 3
5
2 2 3 1 1
7
4 2 3 6 1 1 8
Output
2 1 2 1 
1 1 -1 
2 1 -1 1 2 
2 1 1 3 1 1 4 
----------------------------------------------------------------------------------------------------
E. Count Paths
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 1
1 2
2 3
5
2 1 2 1 2
1 2
1 3
3 4
4 5
5
1 2 3 4 5
1 2
1 3
3 4
4 5
4
2 2 2 2
3 1
3 2
3 4
Output
1
3
0
3
----------------------------------------------------------------------------------------------------
F. Shrink-Reverse
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 2
10010010
Output
7
Input
8 2
01101000
Output
7
Input
30 30
111111111111111111111111111111
Output
73741816
Input
14 1
10110001111100
Output
3197
----------------------------------------------------------------------------------------------------
