5. Determine the maximum number of queens that can be placed on a $2017 \times 2017$ board, such that each queen can attack at most one of the remaining queens.

(Bojan Bašić and the committee)
5. Let $n=2017$. Suppose $m>n$ queens are placed. No row contains more than two queens, so in at least $m-n$ rows, there are two queens, meaning there are at most $m-2(m-n)=2 n-m$ queens that are alone in their row. Similarly, at most $2 n-m$ queens are alone in their column. On the other hand, each queen is alone in its row or column, so $m \leqslant 2(2 n-m)$, from which $m \leqslant\left[\frac{4 n}{3}\right]=2689$.

In Figure A, a placement of 8 queens on a $6 \times 6$ board is shown, in accordance with the problem's requirements. Before constructing an example on a $2017 \times 2017$ board, let's consider the following arrangement of queens:

- On a $335 \times 335$ board, it is possible to place 335 queens that do not attack each other, even if the diagonals are extended modulo 335. Indeed, it is sufficient to place the queens on all squares $(x, y), 1 \leqslant x, y \leqslant 335$, for which $y \equiv 2 x(\bmod 335)$, as shown in Figure B. Indeed, then all sums $x+y$ are distinct modulo 335, and all differences $x-y$ are also distinct, so no two queens are in the same row, column, or diagonal.

Divide the $2017 \times 2017$ board into rectangles and squares with side lengths of 335, 6, and 1, as shown in Figure C. The squares marked B and A will be filled in the order shown in Figures B and A, and one more queen will be placed in the top right cell of the board. This way, we have placed a total of $8 \cdot 335+8+1=2689$ queens. It is easy to verify that this placement satisfies the conditions of the problem.
![](https://cdn.mathpix.com/cropped/2024_06_04_5a6e83cb5d39ea537491g-5.jpg?height=480&width=1462&top_left_y=1676&top_left_x=304)

Note. A $n \times n$ board whose diagonals are extended modulo $n$ is called a toroidal board. On a toroidal $n \times n$ board, it is possible to place $n$ queens that do not attack each other if and only if $n \equiv \pm 1(\bmod 6)$. This has been proven in problem 4 of the SMO 2012.