Codeforces Round 786 (Div. 3)


A. Number Transformation
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3 75
100 100
42 13
Output
2 5
3 1
0 0
----------------------------------------------------------------------------------------------------
B. Dictionary
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
ab
ac
az
ba
bc
zx
zy
Output
1
2
25
26
27
649
650
----------------------------------------------------------------------------------------------------
C. Infinite Replacement
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
aaaa
a
aa
abc
a
b
Output
1
-1
2
----------------------------------------------------------------------------------------------------
D. A-B-C Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
3 1 5 3
3
3 2 1
1
7331
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
E. Breaking the Wall
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
20 10 30 10 20
Output
10
Input
3
1 8 1
Output
1
Input
6
7 6 6 8 5 8
Output
4
Input
6
14 3 8 10 15 4
Output
4
Input
4
1 100 100 1
Output
2
Input
3
40 10 10
Output
7
----------------------------------------------------------------------------------------------------
F. Desktop Rearrangement
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 8
..**
.*..
*...
...*
1 3
2 3
3 1
2 3
3 4
4 3
2 3
2 2
Output
3
4
4
3
4
5
5
5
Input
2 5 5
*...*
*****
1 3
2 2
1 3
1 5
2 3
Output
2
3
3
3
2
----------------------------------------------------------------------------------------------------
G. Remove Directed Edges
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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