Educational Codeforces Round 94 (Rated for Div. 2)


A. String Similarity
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
1
3
00000
4
1110000
2
101
Output
1
000
1010
00
----------------------------------------------------------------------------------------------------
B. RPG Protagonist
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
33 27
6 10
5 6
100 200
10 10
5 5
1 19
1 3
19 5
Output
11
20
3
----------------------------------------------------------------------------------------------------
C. Binary String Reconstruction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
101110
2
01
1
110
1
Output
111011
10
-1
----------------------------------------------------------------------------------------------------
D. Zigzags
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
2 2 2 2 2
6
1 3 3 1 2 3
Output
5
2
----------------------------------------------------------------------------------------------------
E. Clear the Multiset
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
116285317
8
Output
2
Input
314159265359
1
Output
2
Input
13
13
Output
0
Input
3434343434
7
Output
5
----------------------------------------------------------------------------------------------------
G. Mercenaries
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 0
1 1
2 3
1 3
Output
3
Input
3 1
1 1
2 3
1 3
2 3
Output
2
----------------------------------------------------------------------------------------------------
