Helvetic Coding Contest 2024 online mirror (teams allowed, unrated)


A1. Balanced Shuffle (Easy)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
(()(()))
Output
()(()())
----------------------------------------------------------------------------------------------------
A2. Balanced Unshuffle (Medium)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
()(()())
Output
(()(()))
----------------------------------------------------------------------------------------------------
A3. Balanced Unshuffle (Hard)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
()(()())
Output
(()(()))
----------------------------------------------------------------------------------------------------
B1. Exact Neighbours (Easy)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 4 2 4
Output
YES
4 4
1 3
2 4
3 1
1 1 1 3
----------------------------------------------------------------------------------------------------
B2. Exact Neighbours (Medium)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 4 2 4
Output
YES
4 4
1 3
2 4
3 1
1 1 1 3
Input
4
0 1 3 1
Output
YES
1 1
2 1
4 1
3 1
1 1 1 3
----------------------------------------------------------------------------------------------------
B3. Exact Neighbours (Hard)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 4 2 4
Output
YES
4 4
1 3
2 4
3 1
1 1 1 3
Input
4
1 3 0 1
Output
YES
2 1
4 1
1 1
3 1
3 3 3 1
----------------------------------------------------------------------------------------------------
C1. Game on Tree (Easy)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
2 3
3 1
3
Output
Ron
Input
5 1
1 2
2 3
3 4
4 5
5
Output
Hermione
----------------------------------------------------------------------------------------------------
C2. Game on Tree (Medium)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
1 2
1 3
3 4
3 5
1
Output
Ron
----------------------------------------------------------------------------------------------------
C3. Game on Tree (Hard)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 2
1 3
3 4
3 5
1 2
Output
Ron
Ron
Input
6 3
1 2
2 3
1 4
4 5
4 6
1 4 6
Output
Hermione
Ron
Hermione
----------------------------------------------------------------------------------------------------
D1. Arithmancy (Easy)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
15
11
Output
XOXO
X
1 1
2 1
----------------------------------------------------------------------------------------------------
D2. Arithmancy (Medium)
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
15
11
Output
XOXO
X
1 1
2 1
----------------------------------------------------------------------------------------------------
D3. Arithmancy (Hard)
time limit per test: 10 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
15
11
Output
XOXO
X
1 1
2 1
----------------------------------------------------------------------------------------------------
E1. Trails (Easy)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 0 1
0 1 1
Output
18
----------------------------------------------------------------------------------------------------
E2. Trails (Medium)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 0 1
0 1 1
Output
18
----------------------------------------------------------------------------------------------------
E3. Trails (Hard)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 0 1
0 1 1
Output
18
----------------------------------------------------------------------------------------------------
F1. Playing Quidditch (Easy)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
.. R1 .. B1 ..
RG .. .. .. BG
RG R0 .Q B0 BG
RG .. .. .. BG
.. R2 .. B2 ..
13
B2 U
B2 U
B2 L
B2 C .Q
B2 L
B2 L
B2 T
R0 R
R0 C .Q
R0 D
R0 R
R0 R
R0 T
Output
6 BLUE GOAL
12 RED GOAL
FINAL SCORE: 1 1
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
Output
11 BLUE GOAL
FINAL SCORE: 0 1
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
Output
4 BLUE GOAL
FINAL SCORE: 0 1
----------------------------------------------------------------------------------------------------
F2. Playing Quidditch (Medium)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
Output
11 BLUE GOAL
FINAL SCORE: 0 1
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
Output
4 BLUE GOAL
FINAL SCORE: 0 1
Input
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
Output
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0
----------------------------------------------------------------------------------------------------
F3. Playing Quidditch (Hard)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
Output
11 BLUE GOAL
FINAL SCORE: 0 1
Input
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
Output
4 BLUE GOAL
FINAL SCORE: 0 1
Input
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
Output
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0
Input
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
Output
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0
----------------------------------------------------------------------------------------------------
G1. Min-Fund Prison (Easy)
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1 3
1 2
8 7 76
3 1
3 2
2 4
2 5
4 6
4 7
7 8
Output
2
32
----------------------------------------------------------------------------------------------------
G2. Min-Fund Prison (Medium)
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
Output
-1
20
25
33
----------------------------------------------------------------------------------------------------
G3. Min-Fund Prison (Hard)
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
Output
-1
20
25
33
----------------------------------------------------------------------------------------------------
