2023-2024 ICPC, Asia Jakarta Regional Contest (Online Mirror, Unrated, ICPC Rules, Teams Preferred)


A. Easy As ABC
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
BCB
CAC
BCB
Output
ABC
Input
BCB
CCC
CCA
Output
ACB
Input
ACA
CBC
ACA
Output
ABA
Input
ACA
CAC
ACA
Output
AAA
Input
CCC
CBC
CCC
Output
BCC
----------------------------------------------------------------------------------------------------
B. Button Pressing
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2
4
0101
0100
3
000
010
Output
YES
NO
Input
5
7
0101011
1111010
5
11111
00000
4
1101
1101
6
101010
100100
3
000
000
Output
NO
NO
YES
YES
YES
----------------------------------------------------------------------------------------------------
C. Cursed Game
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D. Spaceship Exploration
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
5
0 2
2 0
4 0
4 4
2 4
5
6 1 6 3
2 5 0 0
3 5 3 -1
1 4 5 4
3 4 3 0
Output
2
5.6055512755
8.48528137422
4
-1
Input
4
-10 -9
10 -9
10 9
-10 9
2
0 10 0 -10
-10 -10 -10 -10
Output
200.9975124224
0
Input
8
-20 -10
10 -20
25 -15
35 -5
30 10
15 20
-25 15
-30 5
6
-15 -15 -15 20
-30 -5 30 15
25 20 -5 -20
-5 25 20 -20
-30 10 30 -10
-30 -50 50 0
Output
59.0857761929
103.2455532034
94.7213595500
101.5640991922
164.8528137424
94.3398113206
----------------------------------------------------------------------------------------------------
E. Merge Not Sort
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 4 5 2 6
Output
3 1 6
4 5 2
Input
4
1 2 3 4 5 6 7 8
Output
2 3 5 7
1 4 6 8
Input
2
4 3 2 1
Output
-1
----------------------------------------------------------------------------------------------------
F. Maximize The Value
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2 6
1 1 -50
1 2 -20
2 2 -30
1 1 60
1 2 40
2 2 10
5
1 1 6
2 1 6
1 1 3
2 1 3
1 1 2
Output
100
50
0
0
-20
Input
5 3
1 3 3
2 4 -2
3 5 3
6
1 1 3
2 1 3
3 1 3
3 2 3
2 2 3
2 2 2
Output
3
3
4
3
0
-2
----------------------------------------------------------------------------------------------------
G. Grid Game 2
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3
2 4
Output
FIRST
Input
1
2 2
Output
SECOND
Input
13
1 1
1 4
1 5
2 1
2 4
2 5
4 1
4 2
4 4
5 1
5 2
5 4
5 5
Output
SECOND
----------------------------------------------------------------------------------------------------
H. Twin Friends
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3 4
AMA
ANAB
Output
9
Input
5 8
BINUS
BINANUSA
Output
120
Input
15 30
BINUSUNIVERSITY
BINANUSANTARAUNIVERSITYJAKARTA
Output
151362308
Input
4 4
UDIN
ASEP
Output
0
----------------------------------------------------------------------------------------------------
I. Contingency Plan 2
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
3 2
Output
1
3 1
Input
3
1 2
2 3
Output
0
Input
5
1 2
1 3
3 4
3 5
Output
2
2 3
4 5
----------------------------------------------------------------------------------------------------
J. Count BFS Graph
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
3
Input
3
1 3 2
Output
1
Input
5
1 3 2 4 5
Output
17
Input
11
1 2 3 4 5 6 7 8 9 10 11
Output
379394847
----------------------------------------------------------------------------------------------------
K. Deck-Building Game
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
16 12 4 8
Output
9
Input
4
1 2 4 8
Output
1
Input
2
1 1
Output
5
Input
6
1 1 1 2 2 2
Output
169
----------------------------------------------------------------------------------------------------
L. Palindromic Parentheses
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6 4
Output
(())()
Input
6 3
Output
(()())
Input
4 1
Output
-1
Input
14 11
Output
()((())()())()
----------------------------------------------------------------------------------------------------
M. Triangle Construction
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1 4 6
Output
4
Input
6
1 2 1 2 1 2
Output
3
Input
3
1 1 1
Output
1
----------------------------------------------------------------------------------------------------
