30. What is the minimum number of colors needed to color the cells of a $5 \times 5$ square so that among any three consecutive cells in a row, column, or diagonal, there are no cells of the same color?

(M. Antipov)
30. Answer: in five colors.

Consider a cross of five cells, the central cell of which coincides with the central cell of the square. By the condition, three cells in its column have different colors. Similarly, the colors of the three cells in its row are also different. Finally, any two cells at the "ends" of the cross are also of different colors. For example, cells $A$ and $B$ in the figure have different colors, since by the condition

![](https://cdn.mathpix.com/cropped/2024_05_06_4d459496fe57cc65ed50g-1.jpg?height=217&width=194&top_left_y=771&top_left_x=1776)

among the cells $A, B, C$ there are no cells of the same color. Thus, the colors of all five cells in the cross are different, so there are at least five colors.

An example of coloring in five colors is shown on the right. In this example, each subsequent row is obtained from the previous one by a cyclic shift of two cells to the left.