2022-2023 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules, Preferably Teams)


A. Access Levels
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
01
11
10
Output
2
1 2 
2 2 
1 2 
2 2 
2 1 
Input
2 3
101
100
Output
1
1 1 1
1 10 5
8
3
----------------------------------------------------------------------------------------------------
B. Broken Keyboard
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
ossu
2
aa
6
addonn
3
qwe
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
C. Card Guessing
time limit per test: 15 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
748683266
Input
3 2
Output
567184295
Input
2 7
Output
373153250
Input
2 8
Output
373153250
----------------------------------------------------------------------------------------------------
D. Watch the Videos
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2 3 4 5
Output
16
Input
5 5
1 2 3 4 5
Output
17
Input
4 3
1 3 2 3
Output
12
----------------------------------------------------------------------------------------------------
E. Exchange
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
100 25 30
9999997 25 50
52 50 48
49 50 1
Output
4
400000
1
1
----------------------------------------------------------------------------------------------------
F. Chemistry Lab
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 10
0 10 20
100 15 20
Output
175.000000000000000
Input
2 10
0 100 20
100 150 20
Output
0.000000000000000
Input
6 15
79 5 35
30 13 132
37 3 52
24 2 60
76 18 14
71 17 7
Output
680.125000000000000
Input
10 15
46 11 11
4 12 170
69 2 130
2 8 72
82 7 117
100 5 154
38 9 146
97 1 132
0 12 82
53 1 144
Output
2379.400000000000000
----------------------------------------------------------------------------------------------------
G. Guess the String
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 // 2 test cases
6 // n = 6
0 // p[3] = 0
1 // q[2] = 1
4 // q[6] = 4
1 // p[4] = 1
1 // answer is correct
5 // n = 5
1 // p[2] = 1
2 // q[4] = 2
2 // q[5] = 2
1 // answer is correct
Output
1 3      // what is p[3]?
2 2      // what is q[2]?
2 6      // what is q[6]?
1 4      // what is p[4]?
0 011001 // the guess is 011001
1 2      // what is p[2]?
2 4      // what is q[4]?
2 5      // what is q[5]?
0 00111  // the guess is 00111
----------------------------------------------------------------------------------------------------
H. Hospital Queue
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 1
2 3 2 4
3 1
Output
2 3 1 4 
Input
3 0
3 3 3
Output
1 1 1 
Input
5 3
4 3 3 2 5
3 1
1 5
4 2
Output
4 2 1 1 5 
----------------------------------------------------------------------------------------------------
I. Infinite Chess
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 8
7 8
2
N 4 8
B 4 6
Output
10
Input
1 1
1 5
2
K 1 3
R 2 3
Output
6
Input
2 2
6 4
1
Q 4 3
Output
-1
----------------------------------------------------------------------------------------------------
J. Hero to Zero
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
2 2 2
Output
2
Input
3
3 1 3
1 1 2
Output
5
Input
2
1 0
2 1
Output
2
Input
2
1 4
2 3
Output
4
Input
4
1 3 3 7
6 9 4 2
Output
29
----------------------------------------------------------------------------------------------------
K. Torus Path
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
3 4
Output
8
Input
3
10 10 10
10 0 10
10 10 10
Output
80
----------------------------------------------------------------------------------------------------
L. Project Manager
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 5 4
2 Saturday Sunday
2 Tuesday Thursday
4 Monday Wednesday Friday Saturday
4 7 13 14 15
5 1 1 3 3 2
3 2 3 2
5 3 3 3 1 1
8 3 3 3 3 3 3 3 3
Output
25 9 27 27 
----------------------------------------------------------------------------------------------------
M. Minimum LCM
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2
9
5
10
Output
1 1
3 6
1 4
5 5
----------------------------------------------------------------------------------------------------
N. Number Reduction
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
10000
4
1337
0
987654321
6
66837494128
5
7808652
3
Output
1
1337
321
344128
7052
----------------------------------------------------------------------------------------------------
