Educational Codeforces Round 143 (Rated for Div. 2)


A. Two Towers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 3
BRBB
RBR
4 7
BRBR
RRBRBRB
3 4
RBR
BRBR
5 4
BRBRR
BRBR
Output
YES
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Ideal Point
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 3
1 3
7 9
2 5
3 6
2 9
1 4
3 7
1 3
2 4
3 5
1 4
6 7
5 5
Output
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
C. Tea Tasting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
10 20 15
9 8 6
1
5
7
4
13 8 5 4
3 4 2 1
3
1000000000 1000000000 1000000000
1 1 1000000000
Output
9 9 12 
5 
3 8 6 4 
1 2 2999999997 
----------------------------------------------------------------------------------------------------
D. Triangle Coloring
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
12
1 3 3 7 8 5 2 2 2 2 4 2
Output
36
Input
6
4 2 6 6 6 4
Output
2
----------------------------------------------------------------------------------------------------
E. Explosions?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 1 1
4
4 1 2 1
4
5 10 15 10
1
42
9
1 2 3 2 2 2 3 2 1
Output
3
6
15
42
12
----------------------------------------------------------------------------------------------------
F. Blocking Chips
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
1 2
2 3
3 4
4 5
1
3
5
1 2
2 3
3 4
4 5
2
1 2
5
1 2
2 3
3 4
4 5
2
2 1
6
1 2
1 3
2 4
2 5
3 6
3
1 4 6
1
1
1
Output
2
0
1
2
0
----------------------------------------------------------------------------------------------------
G. Removal Sequences
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2
1 0 1
2 3
1 2
3 3
1 2 0
1 2
2 3
1 3
5 6
3 0 2 1 0
1 2
4 1
4 2
3 4
2 3
5 1
1 0
0
Output
1
0
4
0
----------------------------------------------------------------------------------------------------
