Hello 2023


A. Hall of Fame
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2
LL
2
LR
2
RL
2
RR
7
LLRLLLR
7
RRLRRRL
Output
-1
1
0
-1
3
6
----------------------------------------------------------------------------------------------------
B. MKnez's ConstructiveForces Task
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
3
Output
YES
9 5
NO
----------------------------------------------------------------------------------------------------
C. Least Prefix Sum
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 3
-1 -2 -3 -4
4 3
1 2 3 4
1 1
1
5 5
-2 3 -5 1 -20
5 2
-2 3 -5 -5 -20
10 4
345875723 -48 384678321 -375635768 -35867853 -35863586 -358683842 -81725678 38576 -357865873
Output
1
1
0
0
3
4
----------------------------------------------------------------------------------------------------
D. Boris and His Amazing Haircut
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3
3 3 3
2 1 2
2
1 2
6
3 4 4 6 3 4
3 1 2 3 2 3
3
3 2 3
10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 4 5 6 7 8 9 10
3
1 1 1
1 1 2
12
4 2 4 3 1 5 6 3 5 6 2 1
13
7 9 4 5 3 3 3 6 8 10 3 2 5
5 3 1 5 3 2 2 5 8 5 1 1 5
8
1 5 3 5 4 2 3 1
13
7 9 4 5 3 3 3 6 8 10 3 2 5
5 3 1 5 3 2 2 5 8 5 1 1 5
7
1 5 3 4 2 3 1
3
19747843 2736467 938578397
2039844 2039844 2039844
1
2039844
Output
YES
NO
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
E. Anya's Simultaneous Exhibition
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
1
1
Output
? 1 010
? 2 001
? 3 100
! 111
Input
5
0
3
4
Output
? 5 10110
? 2 10111
? 1 01111
! 10000
----------------------------------------------------------------------------------------------------
F. Xorcerer's Stones
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
13 13
1
Output
1
1
Input
7
5 2 8 3 4 1 31
1 1 2 2 3 3
Output
-1
Input
9
3 31 1 2 7 30 7 3 1
1 1 1 2 5 5 3 4
Output
6
3 2 3 1 2 2
----------------------------------------------------------------------------------------------------
G. The Game of the Century
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
001
001
010
1
0
0
0
3
111
011
100
Output
2
0
3
----------------------------------------------------------------------------------------------------
H. Olympic Team Building
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
60 32 59 87
Output
1001
Input
4
100 100 100 100
Output
1111
Input
8
8 8 8 8 4 4 4 4
Output
11110000
Input
32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Output
00000000000000001111111111111111
Input
16
1 92875987325987 1 1 92875987325986 92875987325985 1 92875987325988 92875987325990 92875987325989 1 1 92875987325984 92875987325983 1 1
Output
0100110111001000
----------------------------------------------------------------------------------------------------
