Educational Codeforces Round 78 (Rated for Div. 2)


A. Shuffle Hashing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
abacaba
zyxaabcaabkjh
onetwothree
threetwoone
one
zzonneyy
one
none
twenty
ten
Output
YES
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
B. A and B
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3
11 11
30 20
Output
3
0
4
----------------------------------------------------------------------------------------------------
C. Berry Jam
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6
1 1 1 2 2 1 2 1 2 1 1 2
2
1 2 1 2
3
1 1 1 1 1 1
2
2 1 1 1
Output
6
0
6
2
----------------------------------------------------------------------------------------------------
D. Segment Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
9 12
2 11
1 3
6 10
5 7
4 8
Output
YES
Input
5
1 3
2 4
5 9
6 8
7 10
Output
NO
Input
5
5 8
3 6
2 9
7 10
1 4
Output
NO
----------------------------------------------------------------------------------------------------
E. Tests for problem D
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2
1 3
3 4
3 5
2 6
Output
9 12
7 10
3 11
1 5
2 4
6 8
Input
1
Output
1 2
----------------------------------------------------------------------------------------------------
F. Cards
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1
Output
1
Input
1 1 5000
Output
1
Input
2 2 2
Output
499122178
Input
998244352 1337 5000
Output
326459680
----------------------------------------------------------------------------------------------------
