Codeforces Round 528 (Div. 1, based on Technocup 2019 Elimination Round 4)


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

Examples
Input
0 0
1 1
2 2
Output
5
0 0
1 0
1 1
1 2
2 2
Input
0 0
2 0
1 1
Output
4
0 0
1 0
1 1
2 0
----------------------------------------------------------------------------------------------------
B. Minimum Diameter Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2
1 3
1 4
Output
2.000000000000000000
Input
6 1
2 1
2 3
2 5
5 4
5 6
Output
0.500000000000000000
Input
5 5
1 2
2 3
3 4
3 5
Output
3.333333333333333333
----------------------------------------------------------------------------------------------------
C. Vasya and Templates
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
bbcb
aada
aada
3
abc
bbb
bbb
Output
YES
badc
NO
----------------------------------------------------------------------------------------------------
D. Rock-Paper-Scissors Champion
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
RPS
1 S
2 R
3 P
1 P
2 P
Output
2
2
1
2
2
3
----------------------------------------------------------------------------------------------------
E. Beautiful Matrix
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
1 2
Output
1
Input
3
1 2 3
2 3 1
3 1 2
Output
1
Input
3
1 2 3
3 1 2
2 3 1
Output
3
----------------------------------------------------------------------------------------------------
F. Forest Fires
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
10 11
Output
40
Input
4 1
2 2
1 3
0 2
2 4
Output
18
Input
3 0
0 0
-2 1
1 1
Output
0
----------------------------------------------------------------------------------------------------
