5. Petya wants to color several cells of a $6 \times 6$ square so that there are as many vertices as possible that belong to exactly three colored squares. What is the maximum number of such vertices he can achieve?
Answer: 25.

Solution. Each vertex of the grid belongs to one, two, or four squares, and the latter are 25. Therefore, the number of vertices in question is no more than 25. An example is shown in the figure.

Criteria. Example: 4 points. Evaluation: 3

points.

![](https://cdn.mathpix.com/cropped/2024_05_06_c413ec7d84bfc8a76c0fg-2.jpg?height=462&width=481&top_left_y=403&top_left_x=893)