Codeforces Round 327 (Div. 1)


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

Examples
Input
4
0 0 1 1
Output
0
0 0 1 1
Input
5
0 1 0 1 0
Output
2
0 0 0 0 0
----------------------------------------------------------------------------------------------------
B. Chip 'n Dale Rescue Rangers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0 5 5
3 2
-1 -1
-1 0
Output
3.729935587093555327
Input
0 0 0 1000
100 1000
-50 0
50 0
Output
11.547005383792516398
----------------------------------------------------------------------------------------------------
C. Three States
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5
11..2
#..22
#.323
.#333
Output
2
Input
1 5
1#2#3
Output
-1
----------------------------------------------------------------------------------------------------
D. Top Secret Task
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
abab
aba
aabab
ababb
bab
Output
2
2 5
----------------------------------------------------------------------------------------------------
