Educational Codeforces Round 25


A. Binary Protocol
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
111
Output
3
Input
9
110011101
Output
2031
----------------------------------------------------------------------------------------------------
B. Five-In-a-Row
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
XX.XX.....
.....OOOO.
..........
..........
..........
..........
..........
..........
..........
..........
Output
YES
Input
XXOXX.....
OO.O......
..........
..........
..........
..........
..........
..........
..........
..........
Output
NO
----------------------------------------------------------------------------------------------------
C. Multi-judge Solving
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2 1 9
Output
1
Input
4 20
10 3 6 3
Output
0
----------------------------------------------------------------------------------------------------
D. Suitable Replacement
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
?aa?
ab
Output
baab
Input
??b?
za
Output
azbz
Input
abcd
abacaba
Output
abcd
----------------------------------------------------------------------------------------------------
E. Minimal Labels
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2
1 3
3 2
Output
1 3 2 
Input
4 5
3 1
4 1
2 3
3 4
2 4
Output
4 1 2 3 
Input
5 4
3 1
2 1
2 3
4 5
Output
3 1 2 4 5 
----------------------------------------------------------------------------------------------------
F. String Compression
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
aaaaaaaaaa
Output
3
Input
abcab
Output
6
Input
cczabababab
Output
7
----------------------------------------------------------------------------------------------------
G. Tree Queries
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6
1 2
2 3
3 4
1 2
1 2
2 2
1 3
2 2
2 2
Output
3
2
1
----------------------------------------------------------------------------------------------------
