AGM 2025, Final Round, Day 2
A. Bridges
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
2 1
1 2 3
Output
1
1 2 3
Input
5 9
2 1 4
3 1 2
4 3 2
5 3 3
2 3 4
4 1 2
4 3 2
1 2 4
2 1 5
Output
2
2 3 4
5 4 3
Input
3 1
1 2 1
Output
2
1 3 1
2 3 1
Input
10 16
1 6 4
2 1 9
5 2 9
3 5 2
4 3 4
9 4 7
8 9 7
10 8 2
7 8 4
2 4 9
5 2 9
5 10 9
9 10 7
9 1 8
9 10 9
2 4 10
Output
3
1 4 8
5 6 8
8 7 4

B. Buldozer
time limit per test
11 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
12 6
4 2 3 1 6 5 9 8 13 5 3 10
1 2
1 3
1 4
2 5
2 7
3 6
6 8
6 9
4 10
8 11
8 12
2 3
1 12 4
2 3
1 5 10
2 2
2 6
Output
44
39
24
36

C. Circles
time limit per test
3 s
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
2
5 0 6
-5 0 6
Output
9.00311

D. Cube
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Example
Input
2
Output
14

E. Edit
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
groot
2 1
root
great
Output
CLOSE
FAR

F. Exam
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 3 3
1 2 3
1 1 1
Output
0
Input
3 3 4
1 2 3
1 1 1
Output
-1
Input
3 0 3
1 2 1
4 3 1
Output
4

G. Matryoshka
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
1
3
Output
2
Input
1
9
Output
4

H. Square
time limit per test
1 second
memory limit per test
128 megabytes
input
standard input
output
standard output
Example
Input
2
Output
12

I. Supporters
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 2
1 2 3
1
1
Output
1
Input
7 10
215 942 988 25 306 945 171
3
7
4
1
Output
332749733
617961713
903173693

J. Threading the Plane
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
4
0 0
4 0
2 4
2 1
Output
6
1 2
1 3
1 4
2 3
2 4
3 4

K. American Truck Simulator
time limit per test
1 second
memory limit per test
250 megabytes
input
standard input
output
standard output
Example
Input
3 2 100
105 100 100
2 50
2 3
1 0
1
Output
2