Codeforces Beta Round 69 (Div. 1 Only)


A. Heroes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180
Output
30 3
Input
2
Anka likes Chapay
Chapay likes Anka
10000 50 50
Output
1950 2
----------------------------------------------------------------------------------------------------
B. Falling Anvils
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 2
1 2
Output
0.6250000000
0.5312500000
----------------------------------------------------------------------------------------------------
C. Beavermuncher-0xFF
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 4
#################
#O..#...#O.O#...#
#.O.#.O.#.O.#...#
#..O#...#O.O#...#
#################
#O.O#OOO#O.O#...#
#.O.#...#...#.O.#
#O.O#OOO#O.O#...#
#################
#O.O#...#O.O#...#
#...#...#...#.O.#
#O.O#...#O.O#...#
#################
Output
3
Input
2 2
#########
#O.O#O.O#
#.O.#...#
#O.O#O.O#
#########
#...#O.O#
#...#...#
#...#O.O#
#########
Output
2
Input
2 2
#########
#..O#O..#
#...#...#
#O..#..O#
#########
#O..#..O#
#...#...#
#..O#O..#
#########
Output
0
----------------------------------------------------------------------------------------------------
E. Martian Food
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 3 1
4 2 2
Output
0.9230769231
0.6666666667
----------------------------------------------------------------------------------------------------
