Codeforces Round 719 (Div. 3)


A. Do Not Be Distracted!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB
Output
NO
NO
YES
YES
YES
----------------------------------------------------------------------------------------------------
B. Ordinary Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1
2
3
4
5
100
Output
1
2
3
4
5
18
----------------------------------------------------------------------------------------------------
C. Not Adjacent Matrix
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
3
Output
1
-1
2 9 7
4 6 3
1 8 5
----------------------------------------------------------------------------------------------------
D. Same Differences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6
3 5 1 4 6 6
3
1 2 3
4
1 3 3 4
6
1 6 3 4 5 6
Output
1
3
3
10
----------------------------------------------------------------------------------------------------
E. Arranging The Sheep
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6
**.*..
5
*****
3
.*.
3
...
10
*.*...*.**
Output
1
0
0
0
9
----------------------------------------------------------------------------------------------------
F1. Guess the K-th Zero (Easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 1
2
2
1
1
0
0
Output
? 4 6
? 1 1
? 1 2
? 2 2
? 5 5
! 5
----------------------------------------------------------------------------------------------------
F2. Guess the K-th Zero (Hard version)
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
2
2
1
1
0
1
0
Output
? 4 6
? 1 1
? 1 2
? 5 5
! 5
? 2 2
! 2
----------------------------------------------------------------------------------------------------
G. To Go Or Not To Go?
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 5 1
0 -1 0 1 -1
0 20 0 0 -1
-1 -1 -1 -1 -1
3 0 0 0 0
-1 0 0 0 0
Output
14
----------------------------------------------------------------------------------------------------
