Codeforces Round 911 (Div. 2)


A. Cover in Water
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
...
7
##....#
7
..#.#..
4
####
10
#...#..#.#
Output
2
2
5
0
2
----------------------------------------------------------------------------------------------------
B. Laura and Operations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
2 3 2
82 47 59
Output
1 1 1
0 1 0
1 0 0
----------------------------------------------------------------------------------------------------
C. Anji's Binary Tree
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
LRU
2 3
0 0
0 0
3
ULR
3 2
0 0
0 0
2
LU
0 2
0 0
4
RULR
3 0
0 0
0 4
2 0
7
LLRRRLU
5 2
3 6
0 0
7 0
4 0
0 0
0 0
Output
0
1
1
3
1
----------------------------------------------------------------------------------------------------
D. Small GCD
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
2 3 6 12 17
8
6 12 8 10 15 12 18 16
Output
24
203
----------------------------------------------------------------------------------------------------
E. Transitive Graph
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 6
2 2 4 1 3
1 2
1 3
2 4
3 4
4 5
5 2
7 7
999999999 999999999 999999999 999999999 1000000000 999999999 1000000000
1 2
2 3
3 4
4 1
4 5
4 6
6 7
14 22
2 3 5 7 3 4 1 4 3 4 2 2 5 1
1 2
2 3
2 4
3 1
4 4
4 5
5 6
5 6
5 12
6 7
6 8
7 5
7 7
7 9
8 4
9 11
10 9
11 10
11 10
12 13
13 14
14 12
Output
5 12
6 5999999995
11 37
----------------------------------------------------------------------------------------------------
F. Local Deletions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 5
1 4 3 6 2 7 5
1 1
1 2
2 3
1 4
1 7
Output
1
1
3
3
3
Input
10 1
1 2 3 4 5 6 7 8 9 10
1 10
Output
1
----------------------------------------------------------------------------------------------------
