Croc Champ 2012 - Round 1


A. Rock-Paper-Scissors
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
RPS
RSPP
Output
3 2
Input
5
RRRRRRRR
R
Output
0 0
----------------------------------------------------------------------------------------------------
B. Chamber of Secrets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
.#.
...
.#.
Output
2
Input
4 3
##.
...
.#.
.#.
Output
2
----------------------------------------------------------------------------------------------------
C. Spiral Maximum
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
0 0 0 0 0
1 1 1 1 1
0 0 0 0 1
1 1 1 0 1
1 0 0 0 1
1 1 1 1 1
Output
17
Input
3 3
1 1 1
1 0 0
1 1 1
Output
6
Input
6 6
-3 2 0 1 5 -1
4 -1 2 -3 0 1
-5 1 2 4 1 -2
0 -2 1 3 -1 2
3 1 4 -3 -2 0
-1 2 -1 3 1 2
Output
13
----------------------------------------------------------------------------------------------------
D. Deputies
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6
1 2
4 1
3 5
6 5
2 6
4 6
Output
YES
1 2 1 2 2 1 
Input
3 1
1 2
Output
NO
----------------------------------------------------------------------------------------------------
E. Camping Groups
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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