[Combinatorics]
Problem: On a $999 \times 999$ board a limp rook can move in the following way: From any square it can move to any of its adjacent squares, i.e. a square having a common side with it, and every move must be a turn, i.e. the directions of any two consecutive moves must be perpendicular. A nonintersecting route of the limp rook consists of a sequence of pairwise different squares that the limp rook can visit in that order by an admissible sequence of moves. Such a non-intersecting route is called cyclic, if the limp rook can, after reaching the last square of the route, move directly to the first square of the route and start over.

How many squares does the longest possible cyclic, non-intersecting route of a limp rook visit?

Solution: First we show that this number is an upper bound for the number of cells a limp rook can visit. To do this we color the cells with four colors $A, B, C$ and $D$ in the following way: for $(i, j) \equiv(0,0) \bmod 2$ use $A$, for $(i, j) \equiv(0,1) \bmod 2$ use $B$, for $(i, j) \equiv(1,0) \bmod 2$ use $C$ and for $(i, j) \equiv(1,1) \bmod 2$ use $D$. From an $A$-cell the rook has to move to a $B$-cell or a $C$-cell. In the first case, the order of the colors of the cells visited is given by $A, B, D, C, A, B, D, C, A, \ldots$, in the second case it is $A, C, D, B, A, C, D, B, A, \ldots$ Since the route is closed it must contain the same number of cells of each color. There are only $499^{2} A$-cells. In the following we will show that the rook cannot visit all the $A$-cells on its route and hence the maximum possible number of cells in a route is $4 \cdot\left(499^{2}-1\right)$.

Assume that the route passes through every single $A$-cell. Color the $A$-cells in black and white in a chessboard manner, i.e. color any two $A$-cells at distance 2 in different color. Since the number of $A$-cells is odd the rook cannot always alternate between visiting black and white $A$-cells along its route. Hence there are two $A$-cells of the same color which are four rook-steps apart that are visited directly one after the other. Let these two $A$-cells have row and column numbers $(a, b)$ and $(a+2, b+2)$ respectively.

<img_3906>

There is up to reflection only one way the rook can take from $(a, b)$ to $(a+2, b+2)$. Let this way be $(a, b) \rightarrow(a, b+1) \rightarrow(a+1, b+1) \rightarrow(a+1, b+2) \rightarrow(a+2, b+2)$. Also let without loss of generality the color of the cell $(a, b+1)$ be $B$ (otherwise change the roles of columns and rows).

Now consider the $A$-cell $(a, b+2)$. The only way the rook can pass through it is via $(a-1, b+2) \rightarrow$ $(a, b+2) \rightarrow(a, b+3)$ in this order, since according to our assumption after every $A$-cell the rook passes through a $B$-cell. Hence, to connect these two parts of the path, there must be



a path connecting the cell $(a, b+3)$ and $(a, b)$ and also a path connecting $(a+2, b+2)$ and $(a-1, b+2)$.

But these four cells are opposite vertices of a convex quadrilateral and the paths are outside of that quadrilateral and hence they must intersect. This is due to the following fact:

The path from $(a, b)$ to $(a, b+3)$ together with the line segment joining these two cells form a closed loop that has one of the cells $(a-1, b+2)$ and $(a+2, b+2)$ in its inside and the other one on the outside. Thus the path between these two points must cross the previous path.

But an intersection is only possible if a cell is visited twice. This is a contradiction.

Hence the number of cells visited is at most $4 \cdot\left(499^{2}-1\right)$.

The following picture indicates a recursive construction for all $n \times n$-chessboards with $n \equiv 3$ mod 4 which clearly yields a path that misses exactly one $A$-cell (marked with a dot, the center cell of the $15 \times 15$-chessboard) and hence, in the case of $n=999$ crosses exactly $4 \cdot\left(499^{2}-1\right)$ cells.

<img_3771>

Final answer: 996000