Codeforces Round 597 (Div. 2)


A. Good ol' Numbers Coloring
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
10 10
1 10
6 9
7 3
Output
Infinite
Finite
Infinite
Finite
----------------------------------------------------------------------------------------------------
B. Restricted RPS
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 1 1
RPS
3
3 0 0
RPS
Output
YES
PSR
NO
----------------------------------------------------------------------------------------------------
C. Constanze's Machine
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ouuokarinn
Output
4
Input
banana
Output
1
Input
nnn
Output
3
Input
amanda
Output
0
----------------------------------------------------------------------------------------------------
D. Shichikuji and Power Grid
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3
1 1
3 2
3 2 3
3 2 3
Output
8
3
1 2 3 
0
Input
3
2 1
1 2
3 3
23 2 23
3 2 3
Output
27
1
2 
2
1 2
2 3
----------------------------------------------------------------------------------------------------
E. Hyakugoku and Ladders
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Output
33.0476190476
Input
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 3 0 0 0 4 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 4 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 4 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 9
Output
20.2591405923
Input
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 6 6 6 6 6 6 0 0 0
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Output
15.9047592939
----------------------------------------------------------------------------------------------------
F. Daniel and Spring Cleaning
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 4
323 323
1 1000000
Output
8
0
3439863766
----------------------------------------------------------------------------------------------------
