2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)


A. Copying Homework
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 2 4
Output
4 2 3 1
Input
2
2 1
Output
1 2
----------------------------------------------------------------------------------------------------
B. Cleaning Robots
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 3
2 3
3 4
4 5
4 6
Output
5
Input
5
1 2
2 3
2 4
4 5
Output
3
----------------------------------------------------------------------------------------------------
C. Even Path
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
6 2 7 8 3
3 4 8 5 1
2 2 1 3
4 2 4 3
5 1 3 4
Output
YES
YES
NO
Input
3 2
30 40 49
15 20 25
2 2 3 3
1 2 2 2
Output
NO
YES
----------------------------------------------------------------------------------------------------
D. Find String in a Grid
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 5
ABC
BCD
DAB
ABC
BC
BD
AC
A
Output
2
3
1
0
2
Input
2 3 3
AAA
AAA
A
AAA
AAAAA
Output
6
4
0
----------------------------------------------------------------------------------------------------
E. Songwriter
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
16 1 8 6
1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 12
Output
1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 8
Input
16 1 8 6
1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 13
Output
-1
Input
16 1 10 10
1 3 5 6 7 8 9 10 3 7 8 9 1 11 12 13
Output
1 2 3 4 5 6 7 8 1 2 3 4 1 2 3 4
----------------------------------------------------------------------------------------------------
F. Regular Forestation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
13
1 5
1 7
2 4
2 8
2 11
3 12
4 7
4 12
6 11
7 13
9 10
9 12
Output
3
Input
6
1 2
1 3
2 4
3 5
3 6
Output
-1
----------------------------------------------------------------------------------------------------
G. Performance Review
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 3
50 40 30 20 10
4 1 2 3 100
1 4
2 6 7
1 3 300
2 1 400
2 1 5
Output
1
0
1
----------------------------------------------------------------------------------------------------
H. Twin Buildings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 5
3 4
Output
12.5
Input
2
2 5
4 3
Output
8.0
Input
3
10 1
9 8
7 6
Output
42.0
----------------------------------------------------------------------------------------------------
I. Mission Possible
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 2 50 26
4 14
48 14
15 13 7
36 16 6
46 18 3
Output
2
13.25 23.1234567
36.591003 7.1
Input
1 0 0 1000 1000
100 501
900 501
500 251 250
Output
0
----------------------------------------------------------------------------------------------------
J. Tiling Terrace
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 4 10 25 40
..#...
Output
75
Input
6 4 10 100 40
..#...
Output
210
Input
7 2 30 10 100
..#...#
Output
160
----------------------------------------------------------------------------------------------------
K. Addition Robot
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
ABAAA
2 1 5 1 1
1 3 5
2 2 5 0 1000000000
Output
11 3
0 1000000000
----------------------------------------------------------------------------------------------------
L. Road Construction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
2 2 1 2
3 2 2 3
4 2 3 4
2 2 4 5
1 2 3 4 5
Output
1 2
2 3
3 4
0 0
4 2
Input
4 5
2 2 10 20
3 2 2 3
4 2 3 4
2 2 4 5
1 2 3 4 5
Output
-1
----------------------------------------------------------------------------------------------------
