Educational Codeforces Round 63 (Rated for Div. 2)


A. Reverse a Substring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
abacaba
Output
YES
2 5
Input
6
aabcfg
Output
NO
----------------------------------------------------------------------------------------------------
B. Game with Telephone Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
13
8380011223344
Output
YES
Input
15
807345619350641
Output
NO
----------------------------------------------------------------------------------------------------
C. Alarm Clocks Everywhere
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
3 12 18
2 6 5 3 3
Output
YES
3 4
Input
4 2
1 5 17 19
4 5
Output
NO
Input
4 2
1 5 17 19
2 1
Output
YES
1 1
----------------------------------------------------------------------------------------------------
D. Beautiful Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 -2
-3 8 -2 1 -6
Output
22
Input
12 -3
1 3 3 7 1 3 3 7 1 3 3 7
Output
42
Input
5 10
-1 -2 -3 -4 -5
Output
0
----------------------------------------------------------------------------------------------------
E. Guess the Root
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
 
1000002
0
Output
? 0
? 1
! 1
Input
 
5
2
1
Output
? 2
? 1
? 0
! -1
----------------------------------------------------------------------------------------------------
F. Delivery Oligopoly
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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