Baltic Way 2024 · Problem 6
Combinatorics
A labyrinth is a system of 2024 caves and 2023 non-intersecting (bidirectional) corridors, each of which connects exactly two caves, where each pair of caves is connected through some sequence of corridors. Initially, Erik is standing in a corridor connecting some two caves. In a move, he can walk through one of the caves to another corridor that connects that cave to a third cave. However, when doing so, the corridor he was just in will magically disappear and get replaced by a new one connecting the end of his new corridor to the beginning of his old one (i.e., if Erik was in a corridor connecting caves and and he walked through cave into a corridor that connects caves and , then the corridor between caves and will disappear and a new corridor between caves and will appear).
Since Erik likes designing labyrinths and has a specific layout in mind for his next one, he is wondering whether he can transform the labyrinth into that layout using these moves. Prove that this is in fact possible, regardless of the original layout and his starting position there.
When you’re ready
Review material becomes available with the next Daily.
Review
Topics
Games and strategies · Invariants and monovariants
Solutions
Solution 1
Throughout the solution, we denote a corridor directly connecting caves and by .
First we show that Erik can reverse his moves. Indeed, consider three caves such that and are corridors, and assume that Erik stands in the corridor . He can then perform the moves in succession (Fig. 1} note that after each move, the edge he is about to walk to in the sequence has just appeared as a consequence of his last move). But this will take him back to where he started as well as make sure that the layout of the labyrinth has not changed. Hence after performing the first move, he can "undo" it by performing the remaining two moves in this sequence.

Figure 1

Figure 2
This means that it is enough to show that Erik can turn any layout into the star shape (i.e., a layout with one central cave that all the remaining caves are directly connected to), since if he can get from any layout to the star shape he can also get from the star shape to any layout. Let us prove this by induction on the number of caves.
For , any allowed layout has the star shape, so let us assume . It is easy to see that there has to exist at least two caves, each of which being connected to only one other cave. These caves cannot be directly connected to each other (otherwise they could not be connected to other caves). Hence one of these two caves, say , is such that Erik is not initially standing in the only corridor adjacent to it. By the induction hypothesis, Erik can then perform some sequence of moves that will transform the labyrinth excluding into the star shape with caves. Let the central cave of the star be and assume that Erik is standing in the corridor . We have to consider three cases for how is connected to other caves:
- The cave is directly connected to . In this case we already have the star shape with caves, and so we are done.
- The cave is directly connected to . In this case Erik can make the moves (Fig. 2). Then the resulting layout has the star shape.
- The cave is directly connected to some other non-central cave . In this case Erik can make the moves
(Fig. 3). Then the resulting layout has the star shape.
In all cases, we have shown that we can turn the labyrinth into the star shape. So we are done by induction.

Figure 3
Solution 2
Clearly, any that works must be a divisor of the number of unit squares. Furthermore, it must not be greater than 45 , or else we cannot fit any rectangles in the grid. This leaves the options and . Note that any divisor of a length that works also works, since we can just divide each of the and pieces into and pieces.
For , we can cover the grid as in Fig. 4. By the above, this shows that and all work.
For , we can cover the grid as in Fig. 5 .

Figure 4

Figure 5
The remaining possibilities are and . All of these are divisible by 4 , and hence if any of them work would also have to work. However, does not work. Indeed, color gray all rows with row numbers congruent to 1 or 2 modulo 4 (Fig. 6). Then any or piece will cover an even number of gray squares. But there is an odd number of gray squares in total, since the number of gray rows is odd, as well as the length of any row, and the center square is white as it is in row 23 . So it is impossible to cover all of them.
Consequently, are the only values that work.

Figure 6
Contest context
Results from Baltic Way 2024
11 teams
- Mean score
- 1.8 / 5
- Scores of 4 or 5
- 3 / 11
- Estonia
- 4 / 5
Score distribution
All team scores
| Team | Score |
|---|---|
| Poland | 2 / 5 |
| Estonia | 4 / 5 |
| Germany | 1 / 5 |
| Ukraine | 5 / 5 |
| Latvia | 4 / 5 |
| Norway | 0 / 5 |
| Lithuania | 0 / 5 |
| Sweden | 1 / 5 |
| Denmark | 3 / 5 |
| Finland | 0 / 5 |
| Iceland | 0 / 5 |