Codeforces Round 877 (Div. 2)


A. Blackboard List
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
3
9 2 7
3
15 -4 11
4
-9 1 11 -10
5
3 0 0 0 3
7
8 16 8 0 8 16 8
4
0 0 0 0
10
27 1 24 28 2 -1 26 25 28 27
6
600000000 800000000 0 -200000000 1000000000 800000000
3
0 -1000000000 1000000000
Output
9
11
-9
3
8
0
-1
600000000
0
----------------------------------------------------------------------------------------------------
B. Minimize Permutation Subarrays
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
4 4
5 7
6 4
Output
16  7  1  9
12  8  2  3
13  4 10 11
14  5  6 15
29 23 17  9  5  6  2
33 27 21 15 11  7  1
32 31 25 19 20 16 10
26 30 24 18 14  8  4
35 34 28 22 13 12  3
 2  3  7 11
 8  9  1 10
17 13  5  4
18 14  6 12
19 23 15 21
20 24 16 22
----------------------------------------------------------------------------------------------------
D. Bracket Walk
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 9
(())()()))
9
7
2
6
3
6
7
4
8
Output
YES
YES
NO
NO
YES
NO
YES
NO
NO
Input
3 2
(()
2
3
Output
NO
NO
----------------------------------------------------------------------------------------------------
E. Count Supersequences
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 1000000 1
1
3 4 3
1 2 2
5 7 8
1 2 3 4 1
6 6 18
18 2 2 5 2 16
1 10 2
1
8 10 1234567
1 1 2 1 2 2 2 1
5 1000000000 1000000000
525785549 816356460 108064697 194447117 725595511
Output
1
9
1079
1
1023
906241579
232432822
----------------------------------------------------------------------------------------------------
F. Stuck Conveyor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
-1 -1
0 2
Output
? 2 2
>><
>>v
^<<
? 1 1
>><
>>v
^<<
! 1 2 ^
Input
4
-1 -1
Output
? 2 2
v>v<
^v<v
v>v^
>v>v
! 3 3 >
----------------------------------------------------------------------------------------------------
