Codeforces Round 343 (Div. 2)


A. Far Relative’s Birthday Cake
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
.CC
C..
C.C
Output
4
Input
4
CC..
C..C
.CC.
.CC.
Output
9
----------------------------------------------------------------------------------------------------
B. Far Relative’s Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
M 151 307
F 343 352
F 117 145
M 24 128
Output
2
Input
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200
Output
4
----------------------------------------------------------------------------------------------------
C. Famil Door and Brackets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
(
Output
4
Input
4 4
(())
Output
1
Input
4 3
(((
Output
0
----------------------------------------------------------------------------------------------------
D. Babaei and Birthday Cake
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
100 30
40 10
Output
942477.796077000
Input
4
1 1
9 7
1 4
10 7
Output
3983.539484752
----------------------------------------------------------------------------------------------------
E. Famil Door and Roads
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 3
2 4
4 1
3 2
3 1
2 3
4 1
Output
4.00000000
3.00000000
3.00000000
Input
3 3
1 2
1 3
1 2
1 3
2 3
Output
2.50000000
2.50000000
3.00000000
----------------------------------------------------------------------------------------------------
