Codeforces Round 934 (Div. 1)


A. MEX Game 1
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
0 0 1 1
4
0 1 2 3
2
1 1
Output
2
1
0
----------------------------------------------------------------------------------------------------
B. Non-Palindromic Substring
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 4
aaab
1 4
1 3
3 4
2 4
3 2
abc
1 3
1 2
5 4
pqpcc
1 5
4 5
1 3
2 4
2 1
aa
1 2
12 1
steponnopets
1 12
Output
9
0
2
5
5
2
14
0
2
5
0
65
----------------------------------------------------------------------------------------------------
C. Tree Compass
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
1 2
4
1 2
1 3
1 4
7
2 7
3 2
6 4
5 7
1 6
6 7
Output
1
1 0
2
1 1
2 1
2
1 1
2 1
3
6 1
7 1
2 1
----------------------------------------------------------------------------------------------------
D1. Counting Is Fun (Easy Version)
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1 998244853
4 1 998244353
3 2 998244353
343 343 998244353
Output
4
7
10
456615865
----------------------------------------------------------------------------------------------------
D2. Counting Is Fun (Hard Version)
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1 998244853
4 1 998244353
3 2 998244353
343 343 998244353
Output
4
7
10
456615865
----------------------------------------------------------------------------------------------------
E1. MEX Game 2 (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4
4 5
2 1000000000
1000000000 1000000000 1000000000
3 2
2 3 100 1
1 1
2 2
3 1
1 1 1 1
Output
2
1
3
2
1
----------------------------------------------------------------------------------------------------
E2. MEX Game 2 (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4
4 5
2 1000000000
1000000000 1000000000 1000000000
3 2
2 3 100 1
1 1
2 2
3 1
1 1 1 1
Output
2
1
3
2
1
----------------------------------------------------------------------------------------------------
F. Minimum Hamming Distance
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
3
000
000
4
0000
1111
6
111111
000100
Output
0
2
1
----------------------------------------------------------------------------------------------------
