Codeforces Round 577 (Div. 2)


A. Important Exam
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
ABCD
ABCE
1 2 3 4
Output
16
Input
3 3
ABC
BCD
CDE
5 4 12
Output
21
----------------------------------------------------------------------------------------------------
B. Zero Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 2
1 3 5
Output
5
Input
5 5
1 2 1 1 1
Output
3
Input
7 7
4 1 2 4 3 4 4
Output
5
----------------------------------------------------------------------------------------------------
D. Treasure Hunting
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 3 2
1 1
2 1
3 1
2 3
Output
6
Input
3 5 3 2
1 2
2 3
3 1
1 5
Output
8
Input
3 6 3 2
1 6
2 2
3 4
1 6
Output
15
----------------------------------------------------------------------------------------------------
E1. Knightmare (easy)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 8
2 3 1 8
Output
WHITE
4 4
Input
6 6
4 4 2 2
6 3
Output
BLACK
4 3
----------------------------------------------------------------------------------------------------
E2. Knightmare (hard)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 8
2 3 1 8
Output
WHITE
4 4
Input
6 6
4 4 2 2
6 3
Output
BLACK
4 3
----------------------------------------------------------------------------------------------------
