Codeforces Round 385 (Div. 2)


A. Hongcow Learns the Cyclic Shift
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
----------------------------------------------------------------------------------------------------
B. Hongcow Solves A Puzzle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
XXX
XXX
Output
YES
Input
2 2
.X
XX
Output
NO
Input
5 5
.....
..X..
.....
.....
.....
Output
YES
----------------------------------------------------------------------------------------------------
C. Hongcow Builds A Nation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1 2
1 3
1 2
Output
2
Input
3 3 1
2
1 2
1 3
2 3
Output
0
----------------------------------------------------------------------------------------------------
D. Hongcow's Game
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
----------------------------------------------------------------------------------------------------
E. Hongcow Buys a Deck of Cards
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
R 0 1
B 1 0
R 1 1
Output
4
Input
3
R 3 0
R 2 0
R 1 0
Output
6
----------------------------------------------------------------------------------------------------
