Codeforces Round 385 (Div. 1)


A. 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
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. Hongcow Draws a Circle
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5
2 3
3 4
1 1
1 4
4 2
4 7
2 5
Output
3.5355338827
Input
1 6
3 3
1 5
5 4
2 1
3 4
4 2
1 3
Output
1.5811388195
Input
2 2
2 2
3 3
1 1
4 4
Output
-1
----------------------------------------------------------------------------------------------------
E. Hongcow Masters the Cyclic Shift
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
ab
b
bba
Output
7
Input
5
hh
ee
ll
ll
oo
Output
0
Input
6
aab
ab
bba
b
ab
c
Output
13
----------------------------------------------------------------------------------------------------
