AGM 2023, Final Round, Day 2
A. Aliens
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
7 6
1 2
1 3
1 7
2 5
2 6
3 4
6 6
2 4
0 6
3 3
6 7
8 8
3 3
1 3
2 3
1 3
2 3
1 2
5 1
Output
0
428571432
0
428571432
500000004
428571432

B. That bird game
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
2
1 3
6 8
Output
4
Input
5
10 10
1 9
6 12
13 19
4 17
Output
345833344
Input
2
1 1
1 2
Output
666666674

C. Boredom
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
2
5 3 0 0 4 5 2 9
3 3 901 899 755 765 723 243
Output
2

D. ExCyc
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
4 2
1 2
2 3
Output
1.500000000

E. Journey
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
7 5
25 6 3
20 2 5
7 3 1
0 2
6 0
WWLDL
WWWWL
WWWWL
WWWWL
WWWLL
WWWWW
DWLLW
Output
150

F. JYEAAP
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5
6 5 21 9 17
Output
499122183 299473341 170 760 499125364 

G. Modulo
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
5 4
6 10 5 9 4
2 2 2 -9
1 7 4 5
2 1 4 1
1 1 2 3
Output
3
1
Input
10 10
9 8 2 5 19 20 3 16 1 12
1 16 2 10
2 7 8 -1
1 12 3 4
1 15 1 1
2 4 6 -3
2 2 7 -1
2 2 4 11
2 3 9 4
1 3 2 2
1 13 3 9
Output
0
0
6
3
3

H. Numbers of Power
time limit per test
1.5 seconds
memory limit per test
128 megabytes
input
standard input
output
standard output
Example
Input
9
5 26 2 16 20 25 33 31 3
5
1 1 9
3 1 9
1 1 9
2 1 9 11
1 2 8
Output
31
26
286

I. Parkour
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
7
17 1 11 13 6 12 16
5
1 4 2
1 5 8
1 7 9
2 6 7 2 17
2 6 6 6 8
Output
45
0

J. SubsetTree
time limit per test
6 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5 2
1 2
1 3
2 4
2 5
0 1 0 0 0
3
2
Output
5
3
15

K. In Sync
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
6 2 6
1 3
2 3
0 3
5 5
0 3
1 4
0 1 2 3 4 5
Output
YES
4
0
1
0
0

L. Yet another points problem
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
6
4 0
6 0
4 100
6 100
0 50
100 50
Output
28