2022 ICPC Asia-Manila Regional Contest
A. An Easy Calculus Problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
-7
Output
-1
Input
0
Output
1
Input
3
Output
2

B. Better than Bitcoin
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
2
3 7 7
8 2 5
Output
2
4
Input
3
1859 19 7
1967 2 17
2000 29 29
Output
213519321
1086566377
0

C. Conform Conforme
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
8 1
2 7 1 8 2 8 1 8
Output
2 1 2 3 2 3 2 3 
Input
7 2
6 7 8 8 8 9 9
Output
2 2 3 3 3 2 2 

D. Domination Devil
time limit per test
6 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
4 1
Output
6
Input
4 2
Output
30
Input
200000 1
Output
1581480553
Input
200000 100000
Output
1212906613

E. Escape from Markov
time limit per test
2.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
4 4 1 4
1 2
2 3
3 4
4 1
2 1 4 3
1 3
Output
2
Input
4 4 1 4
1 2
2 3
3 4
4 1
2 1 4 3
1 2
Output
2
Input
6 5 1 4
1 2
2 3
3 4
4 5
5 6
5 6 5 4
1 6
Output
7
Input
2 1 1 2
1 2
2 1
1 2
Output
IMPOSSIBLE

F. Factions vs The Hegemon
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
5
3 1 4 9 1
Output
4 9
3 8
1 3
2 6
5 12
Input
6
12 4 12 1 1 7
Output
1 12
3 12
5 1
4 7
6 10
2 24

G. Gallivanting Merchant
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
3 5
2 6
6 11
16 21
Output
3
Input
8 4
2 4
9 10
1 2
4 5
5 7
2 10
11 11
11 13
Output
6
Input
4 100
100 101
101 102
102 103
103 104
Output
2

H. HIIT
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
4 6
1 5 2 1
3 7 3 4
Output
1021
Input
5 44
14 11 12 15 8
15 18 17 18 16
Output
20201
Input
5 15
1 2 3 4 5
2 3 4 5 6
Output
11111
Input
5 99
100 101 102 103 104
105 106 107 108 109
Output
00000

I. Item Crafting
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
2 6
2 3 4
3 4 5 6
0 1
0 1
0 1
0 1
Output
1
Input
2 6
2 3 4
3 4 5 6
0 1
0 2
0 1
0 1
Output
2
Input
1 5
2 2 3
2 3 4
2 4 5
0 3
0 2
Output
1
Input
1 4
3 2 3 4
0 2
1 4
0 1
Output
0

J. Junior Steiner Three
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
4 5
.....
..#..
....#
.#...
Output
.....
..#..
.####
.#...
Input
3 3
..#
.#.
#..
Output
..#
###
#..
Input
4 3
..#
.##
...
...
Output
..#
.##
...
...

K. Kapitan Amazing
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
QWERTYU*O*
*SDFGHJK*
ZX*VB**
8
CLAMPING
MAILMAN
PASSWORD
ICPCMANILA
CLIPMAN
CAMPANILLA
ALPACAMANIA
IPAAAAAAAAAAAAAAAAALCMN
Output
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE
POSSIBLE
POSSIBLE
POSSIBLE
POSSIBLE
POSSIBLE
Input
QWERTYUIOP
*SDFGHJKL
ZXCVBNM
5
A
AA
AAAA
AAAAAAAA
AAAAAAAAHHHHHHHH
Output
POSSIBLE
POSSIBLE
POSSIBLE
POSSIBLE
IMPOSSIBLE

L. LCG Manipulation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
8
2 3 1 7 5
2 3 1 7 6
2 3 1 7 1
2 3 1 7 0
7 1 2 31 24
7 1 2 31 25
7 1 2 31 26
7 1 1 31 26
Output
1
2
0
IMPOSSIBLE
6
4
IMPOSSIBLE
2
Input
2
314159265 1234567890 2022 2147483647 2023
1234567890 314159265 2022 2147483647 2023
Output
1058977885
IMPOSSIBLE