AGM 2024, Final Round, Day 1
A. Autocomplete
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
5
1 1 2 3
abczz
3
abz
ace
a*z
Output
1
0
2

B. Bob
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
8
1 1 1 1 0 1 0 1
Output
18

C. Dark Matter
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5 5
1 2 3 4 5
0 0 2 3
1 3 4 3
1 2 4 3
3 0 3 3
2 2 3 3
Output
4
5
4
3
1

D. Golf
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
10 1 7
2 4
8 8
1 3
Output
2.333333
Input
10 1 7
2 5
8 11
1 3
Output
3.166667
Input
10 10 0
2 4
1 2
2 2
Output
4.000000

E. K Segments
time limit per test
2.5 seconds
memory limit per test
250 megabytes
input
standard input
output
standard output
Example
Input
8 3
12 5 7 4 6 13 5 14
Output
7

F. Magic Path
time limit per test
3 с
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
6 13
2 1
3 1
4 1
2 5
4 6
27 16 9 30 9 38
Output
432

G. Origami
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
3
0 5
0 0
1 0
Output
Yes

H. Quantum Realms
time limit per test
1.5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
2 2
00
00
0 0 0 0
5 6 0 0
0 0 0 0
0 0 0 0
1 4
1 2
Output
10
Input
3 3
000
010
000
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
2 1
3 3
4 1
Output
11
Input
4 2
00
11
11
00
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 1
2 2
Output
-1
Input
5 5
00000
01110
01010
10110
00000
0 9 7 9
8 5 9 9
1 8 5 3
6 9 6 2
3 2
2 4
4 3
1 1
2 4
Output
45

I. Starry Night
time limit per test
10 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
1 4
0 0
-1 -1
-1 1
1 1
1 -1
Output
1.414214
Input
2 2
-1 -1
1 1
-2 2
2 -2
Output
2.828427
Input
3 3
0 0
1 1
0 2
-100000000 -100000000
-99999999 -99999999
-100000000 -99999998
Output
0.000000
Input
5 20
401 -924
-804 641
-659 -864
239 -295
-329 883
873 788
613 627
770 124
-152 -49
697 -123
161 -104
701 63
-343 146
122 656
-99 -710
-156 -197
-869 -152
-414 -699
-599 -709
-365 -568
420 883
353 919
546 901
485 30
672 -575
Output
575.692976

J. Students
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
9
Output
6
7

K. The Great Treasure Dilemma
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
5 5
Output
10
Input
27 5
Output
224
Input
8 3
Output
20
Input
1000 28
Output
267430121

L. The Tree-Mendous Game of Stones
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
5 5
1 2
1 3
3 4
3 5
1
11
2
3
6
Output
Bob
Input
10 8
1 4
1 7
2 9
3 4
3 5
3 9
6 7
6 8
7 10
31
28
37
14
30
3
2
40
Output
Alice
Input
3 2
1 2
1 3
8
10
Output
Alice