Educational Codeforces Round 73 (Rated for Div. 2)


A. 2048 Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
1024 512 64 512
1
2048
3
64 512 2
2
4096 4
7
2048 2 2048 2048 2048 2048 2048
2
2048 4096
Output
YES
YES
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. Knights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
WBW
BBB
WBW
----------------------------------------------------------------------------------------------------
C. Perfect Team
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1 1
3 6 0
0 0 0
0 1 1
10 1 10
4 4 1
Output
1
3
0
0
1
3
----------------------------------------------------------------------------------------------------
D. Make The Fence Great Again
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
2 4
2 1
3 5
3
2 3
2 10
2 6
4
1 7
3 3
2 6
1000000000 2
Output
2
9
0
----------------------------------------------------------------------------------------------------
E. Game With String
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
XX......XX...X
4 2
X...X.X..X
5 3
.......X..X
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
F. Choose a Square
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 0 2
1 0 -5
1 1 3
2 3 4
1 4 -4
3 1 -1
Output
4
1 1 3 3
Input
5
3 3 0
3 3 -3
0 2 -1
3 1 3
0 0 -2
Output
0
1 1 1 1
----------------------------------------------------------------------------------------------------
G. Graph And Numbers
time limit per test: 3.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 5
1 2
2 3
3 4
4 5
5 1
Output
20
Input
4 4
1 2
2 3
3 4
4 1
Output
4
Input
35 29
1 2
2 3
3 1
4 1
4 2
3 4
7 8
8 9
9 10
10 7
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
Output
34201047040
----------------------------------------------------------------------------------------------------
