Educational Codeforces Round 159 (Rated for Div. 2)


A. Binary Imbalance
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
00
2
11
2
10
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Getting Points
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 5 5 2
14 3000000000 1000000000 500000000
100 20 1 10
8 120 10 20
42 280 13 37
Output
0
12
99
0
37
----------------------------------------------------------------------------------------------------
C. Insert and Equalize
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2 3
5
1 -19 17 -3 -15
1
10
Output
6
27
1
----------------------------------------------------------------------------------------------------
D. Robot Queries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 3
RDLLUURU
-1 2 1 7
0 0 3 4
0 1 7 8
Output
YES
YES
NO
Input
4 2
RLDU
0 0 2 2
-1 -1 2 3
Output
YES
NO
Input
10 6
DLUDLRULLD
-1 0 1 10
-1 -2 2 5
-4 -2 6 10
-1 0 3 9
0 1 4 7
-3 -1 5 8
Output
YES
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
E. Collapsing Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
aba
ab
ba
Output
20
Input
5
abab
babx
xab
xba
bab
Output
126
----------------------------------------------------------------------------------------------------
F. Trees and XOR Queries Again
time limit per test: 6.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
0 1 2 10
2 1
3 2
4 2
8
3 3 0
3 4 1
3 4 7
1 3 1
1 3 2
1 3 10
1 4 10
1 4 11
Output
YES
YES
NO
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
