Educational Codeforces Round 132 (Rated for Div. 2)


A. Three Doors
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
0 1 2
1
0 3 2
2
3 1 0
2
1 3 0
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
B. Also Try Minecraft
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 6
10 8 9 6 8 12 7
1 2
1 7
4 6
7 1
3 5
4 2
Output
2
10
0
7
3
1
----------------------------------------------------------------------------------------------------
C. Recover an RBS
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
(?))
??????
()
??
?(?)()?)
Output
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
D. Rorororobot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11 10
9 0 0 10 3 4 8 11 10 8
6
1 2 1 3 1
1 2 1 3 2
4 3 4 5 2
5 3 11 5 3
5 3 11 5 2
11 9 9 10 1
Output
YES
NO
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
E. XOR Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 2 1 3 2 1
4 5
3 4
1 4
2 1
6 1
Output
2
Input
4
2 1 1 1
1 2
1 3
1 4
Output
0
Input
5
2 2 2 2 2
1 2
2 3
3 4
4 5
Output
2
----------------------------------------------------------------------------------------------------
F. Multiset of Strings
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 42 2
Output
3
Input
2 37 13
Output
36871576
Input
4 1252 325
Output
861735572
Input
6 153 23699
Output
0
Input
15 200000 198756
Output
612404746
----------------------------------------------------------------------------------------------------
