Codeforces Round 374 (Div. 2)


A. One-dimensional Japanese Crossword
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
BBW
Output
1
2 
Input
5
BWBWB
Output
3
1 1 1 
Input
4
WWWW
Output
0
Input
4
BBBB
Output
1
4 
Input
13
WBBBBWWBWBBBW
Output
3
4 1 3 
----------------------------------------------------------------------------------------------------
B. Passwords
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
----------------------------------------------------------------------------------------------------
C. Journey
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 13
1 2 5
2 3 7
2 4 8
Output
3
1 2 4 
Input
6 6 7
1 2 2
1 3 3
3 6 3
2 4 2
4 6 2
6 5 1
Output
4
1 2 4 6 
Input
5 5 6
1 3 3
3 5 3
1 2 2
2 4 3
4 5 2
Output
3
1 3 5 
----------------------------------------------------------------------------------------------------
D. Maxim and Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 1
5 4 3 5 2
Output
5 4 3 5 -1 
Input
5 3 1
5 4 3 5 5
Output
5 4 0 5 5 
Input
5 3 1
5 4 4 5 5
Output
5 1 4 5 5 
Input
3 2 7
5 4 2
Output
5 11 -5 
----------------------------------------------------------------------------------------------------
E. Road to Home
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
17 2 2 6
0 9
13 17
Output
5
Input
12 2 2 2
0 5
6 11
Output
4
Input
12 2 2 4
0 5
6 11
Output
3
----------------------------------------------------------------------------------------------------
