Educational Codeforces Round 42 (Rated for Div. 2)


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

Examples
Input
4
1 3 2 1
Output
2
Input
6
2 2 2 2 2 2
Output
3
----------------------------------------------------------------------------------------------------
B. Students in Railway Carriage
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 1
*...*
Output
2
Input
6 2 3
*...*.
Output
4
Input
11 3 10
.*....**.*.
Output
7
Input
3 2 3
***
Output
0
----------------------------------------------------------------------------------------------------
C. Make a Square
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8314
Output
2
Input
625
Output
0
Input
333
Output
-1
----------------------------------------------------------------------------------------------------
D. Merge Equals
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 4 1 2 2 1 1
Output
4
3 8 2 1 
Input
5
1 1 3 1 1
Output
2
3 4 
Input
5
10 40 20 50 30
Output
5
10 40 20 50 30 
----------------------------------------------------------------------------------------------------
E. Byteland, Berland and Disputed Cities
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
-5 R
0 P
3 P
7 B
Output
12
Input
5
10 R
14 B
16 B
21 R
32 R
Output
24
----------------------------------------------------------------------------------------------------
F. Simple Cycles Edges
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2
2 3
3 1
Output
3
1 2 3 
Input
6 7
2 3
3 4
4 2
1 2
1 5
5 6
6 1
Output
6
1 2 3 5 6 7 
Input
5 6
1 2
2 3
2 4
4 3
2 5
5 3
Output
0
----------------------------------------------------------------------------------------------------
G. Visible Black Areas
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8
Output
2
----------------------------------------------------------------------------------------------------
