Daily

Random

Practice set

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 aa and bb and he walked through cave bb into a corridor that connects caves bb and cc, then the corridor between caves aa and bb will disappear and a new corridor between caves aa and cc 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.

Change pool

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 aa and bb by aba b. First we show that Erik can reverse his moves. Indeed, consider three caves a,b,ca, b, c such that aba b and bcb c are corridors, and assume that Erik stands in the corridor aba b. He can then perform the moves ab→bc→ca→aba b \rightarrow b c \rightarrow c a \rightarrow a b 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. Official solution diagram for Baltic Way 2024 Problem 6 (Figure 1).

Figure 1 Official solution diagram for Baltic Way 2024 Problem 6 (Figure 2).

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 nn of caves.

For n=3n=3, any allowed layout has the star shape, so let us assume n≥4n \geq 4. 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 vv, 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 vv into the star shape with n−1n-1 caves. Let the central cave of the star be cc and assume that Erik is standing in the corridor cwc w. We have to consider three cases for how vv is connected to other caves:

  • The cave vv is directly connected to cc. In this case we already have the star shape with nn caves, and so we are done.
  • The cave vv is directly connected to ww. In this case Erik can make the moves cw→wv→vcc w \rightarrow w v \rightarrow v c (Fig. 2). Then the resulting layout has the star shape.
  • The cave vv is directly connected to some other non-central cave uu. In this case Erik can make the moves
wc→cu→uw→uv→vw→wc→wu→ucw c \rightarrow c u \rightarrow u w \rightarrow u v \rightarrow v w \rightarrow w c \rightarrow w u \rightarrow u c

(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. Official solution diagram for Baltic Way 2024 Problem 6 (Figure 3).

Figure 3

Solution 2

Clearly, any nn that works must be a divisor of the number 452−1=202445^{2}-1=2024 of unit squares. Furthermore, it must not be greater than 45 , or else we cannot fit any 1×n1 \times n rectangles in the grid. This leaves the options n=1,n=2,n=4,n=8,n=11,n=22,n=23n=1, n=2, n=4, n=8, n=11, n=22, n=23 and n=44n=44. Note that any divisor dd of a length nn that works also works, since we can just divide each of the 1×n1 \times n and n×1n \times 1 pieces into 1×d1 \times d and d×1d \times 1 pieces.

For n=22n=22, we can cover the grid as in Fig. 4. By the above, this shows that n=1,n=2n=1, n=2 and n=11n=11 all work.

For n=23n=23, we can cover the grid as in Fig. 5 . Official solution diagram for Baltic Way 2024 Problem 6 (Figure 4).

Figure 4 Official solution diagram for Baltic Way 2024 Problem 6 (Figure 5).

Figure 5

The remaining possibilities are n=4,n=8n=4, n=8 and n=44n=44. All of these are divisible by 4 , and hence if any of them work n=4n=4 would also have to work. However, n=4n=4 does not work. Indeed, color gray all rows with row numbers congruent to 1 or 2 modulo 4 (Fig. 6). Then any 1×41 \times 4 or 4×14 \times 1 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, n=1,2,11,22,23n=1,2,11,22,23 are the only values that work. Official solution diagram for Baltic Way 2024 Problem 6 (Figure 6).

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

04
12
21
31
42
51
All team scores
TeamScore
Poland2 / 5
Estonia4 / 5
Germany1 / 5
Ukraine5 / 5
Latvia4 / 5
Norway0 / 5
Lithuania0 / 5
Sweden1 / 5
Denmark3 / 5
Finland0 / 5
Iceland0 / 5