Educational Codeforces Round 53 (Rated for Div. 2)


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

Examples
Input
10
codeforces
Output
YES
code
Input
5
aaaaa
Output
NO
----------------------------------------------------------------------------------------------------
B. Vasya and Books
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
RURUU
-2 3
Output
3
Input
4
RULR
1 1
Output
0
Input
3
UUU
100 100
Output
-1
----------------------------------------------------------------------------------------------------
D. Berland Fair
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 38
5 2 5
Output
10
Input
5 21
2 4 100 2 6
Output
6
----------------------------------------------------------------------------------------------------
E. Segment Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 50 2
Output
1230
Input
1 2345 10
Output
2750685
Input
101 154 2
Output
2189
----------------------------------------------------------------------------------------------------
F. Choosing Two Paths
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 4
1 5
1 6
2 3
2 4
4 7
Output
3 6
7 5
Input
9
9 3
3 5
1 2
4 3
4 7
1 7
4 6
3 8
Output
2 9
6 8
Input
10
6 8
10 3
3 7
5 8
1 7
7 2
2 9
2 8
1 4
Output
10 6
4 5
Input
11
1 2
2 3
3 4
1 5
1 6
6 7
5 8
5 9
4 10
4 11
Output
9 11
8 10
----------------------------------------------------------------------------------------------------
G. Yet Another LCP Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
abacaba
2 2
1 2
1 2
3 1
1 2 3
7
1 7
1
1 2 3 4 5 6 7
2 2
1 5
1 5
Output
13
2
12
16
----------------------------------------------------------------------------------------------------
