2024 Taiwan NHSPC Mock Contest (Mirror)
A. Challenges in Bolivia (challenges)
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
3 4
1 3 3
5 2 3 1
4 1 2 0
Output
2 1 3 
Input
6 4
11 20 14 30 5 1
1 2 4 5
0 3 4 1
Output
-1

B. Growing Cucumbers (cucumber)
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
2
11 41
8
2 1
-1 -1
Output
11 19
Input
3
10 32123432332 4322214322123
71 22
1 2 3
-1 1 -1
Output
10 1 23
Input
10
4 14 12 6 12 19 12 18 18 1
3 2 0 8 7 3 0 2 9
3 10 1 8 2 9 6 4 7 5
1 -1 -1 1 1 -1 1 -1 1 1
Output
4 1 1 1 1 1 1 1 3 1

C. Get Out Away (getoutaway)
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
5
3 4 2
1 2 6
4 2 5
2 5 3
Output
13 9
Input
5
3 4 1
1 2 2
4 2 1
2 5 2
Output
4 4

D. Building Gondola (gondola)
time limit per test
7 seconds
memory limit per test
2048 MB
input
standard input
output
standard output
Examples
Input
4 5 1 2
X?..
X.X?
?X??
XX?.
?X?X
1 1 4
2 1 4
Output
1
1
Input
3 5 1 2
.?.
.?X
X?X
X?X
X?X
1 1 2
1 2 3
Output
2
4
Input
4 2 1 2
X.X.
X.X.
2 1 4
0 2 3
Output
2
0
Input
6 6 2 7
?.?..?
??.X.?
?X?X.?
?X??XX
.X???X
??XX??
0 4 6
3 1 6
2 2 5
0 4 5
1 3 5
1 5 6
2 1 4
Output
0
12
4
0
4
3
9

E. Horse Racing In The Wilderness (horse)
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
5
1 2 3 4 5
1 3 2 6 7
2 3 9 11 9
Output
Yes
1 2 3 4 5
1 3 3 6 7
Input
5
0 2 0 3 0
1 2 3 3 4
2 4 4 4 5
Output
Yes
1 2 4 3 5
1 2 3 3 4
Input
5
0 2 0 1 0
1 2 3 4 1
2 3 4 5 5
Output
No

F. Railway Renovation (rail)
time limit per test
3 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
4 4
1 2
2 3
3 4
4 1
Output
RBRB
Input
4 4
1 2
2 3
3 1
1 4
Output
RBRB
Input
4 5
1 2
1 3
1 4
2 3
3 4
Output
RRBBR

G. Soccer (soccer)
time limit per test
7 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
3 3
0 0
2 5
5 3
1 3
2 8
2 2
Output
3
Input
5 8
0 0
1 64
2 36
3 10
4 10
1 47
1 26
3 51
2 5
2 11
4 67
4 24
3 8
Output
16
Input
10 18
0 0
1 91
2 7
3 27
4 99
5 93
6 38
7 30
8 54
9 43
8 75
7 86
5 10
2 22
8 69
6 83
4 88
5 99
1 38
3 78
9 69
1 30
4 17
2 78
6 65
7 42
9 32
3 76
Output
198

H. The Taiko Problem (taiko)
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
16 3 3
DDK.DDK.DDK.DDK.
Output
12
Input
16 1 3
DDK.DDK.DDK.DDK.
Output
7
Input
28 4 3
K.DDK.D.K.DDK.D.KKK.D.D.K...
Output
7

I. Huge Cannon Volleyball (volleyball)
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
2 1
0 1
2 2
Output
1
1 2 
Input
5 2
0 0 4 0 3
2 3
Output
2
1 4 3 5 2 
Input
10 0
0 0 0 0 0 0 0 0 0 0
2 1
Output
572637895
1 2 3 4 5 6 7 8 9 10