Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2)


A. Increasing and Decreasing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 4 3
1 3 3
100 200 4
Output
1 3 4
-1
100 150 180 200
----------------------------------------------------------------------------------------------------
B. Swap and Reverse
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 2
nima
5 3
panda
9 2
theforces
7 3
amirfar
6 4
rounds
Output
aimn
aandp
ceefhorst
aafmirr
dnorsu
----------------------------------------------------------------------------------------------------
C. Divisor Chain
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
5
14
Output
3
3 2 1
4
5 4 2 1
6
14 12 6 3 2 1
----------------------------------------------------------------------------------------------------
D. Matrix Cascade
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5
00100
01110
11111
11111
11111
3
100
110
110
6
010101
111101
011110
000000
111010
001110
Output
1
2
15
----------------------------------------------------------------------------------------------------
E. Guess Game
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
2 3
3
0 0 0
3
9 9 6
8
34124838 0 113193378 8 321939321 113193378 9463828 99
Output
499122179
1
332748120
77987843
----------------------------------------------------------------------------------------------------
F. Exotic Queries
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
10 8
1 6 2 3 2 6 3 10 1 2
1 10
2 2
3 3
2 3
1 3
3 6
4 6
5 5
Output
8
1
1
3
5
3
1
0
Input
3 1
1 3 2
1 3
Output
3
----------------------------------------------------------------------------------------------------
G. Magic Square
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 3
4 5 6
7 8 9
7 2 3
1 4 5
6 8 9
3
1 2 3
4 5 6
7 8 9
3 2 1
6 5 4
9 7 8
3
1 2 3
4 5 6
7 8 9
7 8 1
2 3 4
5 6 9
3
1 2 3
4 5 6
7 8 9
3 8 4
5 1 9
7 6 2
Output
1
0
0
4
----------------------------------------------------------------------------------------------------
H. Asterism Stream
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1
4
8
15
998244353
296574916252563317
494288321850420024
Output
0
499122179
717488133
900515847
93715054
44488799
520723508
----------------------------------------------------------------------------------------------------
I. Future Dominators
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4
1 1
6 6
3 0
1 2
3 9
2 1
8 11
4 4
4 4
2 0
4 4
11 10
1 3
3 2
1 1
1 1
Output
4 2 3 1 
9 7 6 3 5 8 2 1 4 
1 
----------------------------------------------------------------------------------------------------
