Codeforces Round 499 (Div. 1)


A. Fly
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
12
11 8
7 5
Output
10.0000000000
Input
3
1
1 4 1
2 5 3
Output
-1
Input
6
2
4 6 3 3 5 6
2 6 3 6 5 3
Output
85.4800000000
----------------------------------------------------------------------------------------------------
B. Rocket
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1
-1
-1
1
0
Output
1
2
4
5
3
----------------------------------------------------------------------------------------------------
C. Border
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 8
12 20
Output
2
0 4 
Input
3 10
10 20 30
Output
1
0 
----------------------------------------------------------------------------------------------------
D. Mars rover
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
AND 9 4
IN 1
IN 1
XOR 6 5
AND 3 7
IN 0
NOT 10
IN 1
IN 1
AND 2 8
Output
10110
----------------------------------------------------------------------------------------------------
E. Store
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 10 10 3 1 3
2 6 2
4 2 4
6 4 6
9 9 9
3 3 3
10 10 10
8 8 8
Output
CORRECT
OPEN
CLOSED
UNKNOWN
Input
10 10 10 1 1 1
2 5 7
2 5 7
8 9 10
Output
INCORRECT
----------------------------------------------------------------------------------------------------
F. Tree
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2
1 3
Output
13
Input
2 5
1 2
Output
7
Input
4 10
1 2
1 3
3 4
Output
441
----------------------------------------------------------------------------------------------------
