Skip to main content
OlympiadHQ

Browse · MathNet

Print

China-TST-2023B

China 2023 counting and probability

Problem

Given a positive integer , find the smallest positive integer with the following property: After coloring any unit squares black and the remaining squares white in a grid, it is always possible to make all squares black using a finite number of the following two operations:

(Operation 1) Select a square that contains exactly 3 black squares and 1 white square, and change the color of the white square to black.

(Operation 2) Select a square that contains exactly 2 black squares and 2 white squares, and change the color of all squares within the square (black squares become white, and white squares become black).

Note: The same square can be operated on multiple times, and each square can change color multiple times.

problem


problem
Solution
Proof. The desired value of is .

First, we provide an example of coloring cells black, such that it is impossible to perform operation 1. This implies that .

Color the anti-diagonal cells black, and then color black all the cells in the top-left part of the anti-diagonal, where both and are odd and . Similarly, color black all the cells in the bottom-right part of the anti-diagonal, where both and are even and . (The following diagram illustrates the case of , where the cells marked with are colored black.)



It can be seen that a total of cells are colored black, and they satisfy the following property.

For any two black cells and in the same row with , there exists such that cells , , and are all white. Similarly, for any two black cells and in the same column with , there exists such that cells , , and are all white. Here, all cells in the 0th row, the th row, the 0th column, and the th column are considered white.

Note that if a state satisfies , then in any rectangle, there can be at most 2 black cells (otherwise, either two black cells share a common edge, or there exists a white cell that has three black cells adjacent to it, both of which violate ).

Now we will prove that for any operation performed on the diagram, it can only be operation 2, and the two colored cells will not share a common edge. Additionally, property will continue to hold. If this statement is true, it implies that it is impossible to completely color all cells black. The initial state clearly satisfies the above assertion. Assuming the assertion holds after some operations, we will show that after performing one operation 2, property will still be satisfied. Due to symmetry, we only need to consider the resulting cells and . We will discuss two cases.

Case 1: Both and are originally black cells. In this case, there exists such that cells , , and are all white. Note





(The scripts in the figure is: “at most black cells.”) If the operation does not increase the number of black cells in this rectangle, then there must still be a column in these three rows with no black cells, which satisfies property . If the operation increases the number of black cells in the rectangle, then by the description of operation 2 and the fact that any two black cells were not adjacent, it must involve adding a black cell to one of the corners of the upper rectangle. In this case, prior to the operation, either , , , or must have at least one black cell. However, this configuration would result in two black cells sharing a common edge, which is a contradiction!

Case 2: One of and is a newly colored black cell (the two newly colored cells are in different rows and different columns, so both and cannot be new cells). Without loss of generality, let's assume is the newly colored cell. Also, due to symmetry, let's assume the operation occurs in a rectangle in the th and th rows. If the operation involves changing and from black to white, and changing and from white to black, then prior to the operation, using property for and , we know that there exists such that cells , , and are all white. Therefore, after the operation, this still satisfies property . If the operation involves changing and from black to white, and changing and from white to black, then prior to the operation, using property for and , we know that there exists such that cells , , and are all white. Additionally, it is clear that , so this still satisfies property .

Next, we will prove that satisfies the conditions. To do this, we need to show that if the number of black cells is not less than and there is at least one white cell, then it is possible to perform several operations 2 followed by one operation 1. We will use a proof by contradiction. First, we prove a lemma.

Lemma: Let be the number of black cells in the th row. If , then it is possible to perform some operations 2 in the th, th, and th rows such that (within this rectangle) there are two black cells with a common edge (where ).



Proof of the Lemma:** We first prove that it is possible to perform some operations 2 in the th, th, and th rows without changing , , and , such that (within this rectangle) there is either a row or a column with two black cells having a common edge. Assuming otherwise, it means that there are no rows or columns with two black cells having a common edge in the current state. Let the black cells in the th row be in columns with . If in the th, th, and th rows, there are at most black cells in columns (), then the first columns in these three rows have at most black cells, and the last columns have at most black cells. Hence, we have , which is a contradiction.

If there are more than black cells in the first columns or more than black cells in the last columns, it can also be concluded that there is a rectangle with at least 3 black cells. In this case, there must be three black cells that do not share a common edge. Performing one operation 2 on two of these cells will result in two black cells in a column with a common edge, without changing , , and .

If there exists such that there are at least black cells in columns in these three rows, we first note that if there are two adjacent columns in these three rows that have at least 3 black cells, we can similarly perform operation 2 to make two black cells adjacent. Assuming this case does not occur, in particular, the columns and have at most 1 black cell each. However, the sum of the number of black cells in columns in these three rows is at least . By simple analysis, we can see that both the column and the column in these three rows must have exactly one black cell. After performing operation 2 on and the black cell in the column, both and will be black cells, and there will still be at least black cells in columns . Repeat this discussion and operation until the last two black cells in the th row are adjacent.

Now if there are two black cells with a common edge in the same row, the conclusion is already established. If there are two black cells with a common edge in the same column, we can perform operations to move them horizontally. Note that both rows cannot have only one black cell (otherwise, the other row would have at least black cells, which would lead to two black cells with a common edge within that row). Therefore, it is always possible to perform operations to have two black cells with a common edge in the same row, and the lemma is proved.

Returning to the original problem, we have where . If , then the first row has two consecutive black cells. If , then there exists such that and by the lemma, we can perform some operations 2 within these three rows to have two black cells with a common edge within a single row.

Assume these two cells are located in the th column and the st column. Let and be the maximum positive integers such that there are black cells in the columns . If one of these columns has at least 2 black cells, let's say the column . We perform operations 2 on and until the black cell in the th row is in the same row as the black cell in the th column. Then, we perform operations on the st and th columns to make the black cell in the st column in the same row as one of the black cells in the nd column, and so on. Finally, we can make the black cell in the th column in the same row as one of the black cells in the th column. Then, we perform operations on the th and th columns to bring these two cells close to another black cell in the th column, forming a square with at least 3 black cells (if operations 2 cannot be performed during this process, it means that a similar situation has occurred). If this square can be transformed by operation 1, then the conclusion is already established. If not, then all four cells in this square are black. We can move these four black cells upwards, downwards, leftwards, or rightwards until they encounter another black cell. At this point, if it is not possible to perform operation 1, it means that a rectangle has been formed with all four cells being black. Considering the three cells on the other side of an edge with length 3, if one or two of them are black, operation 1 can be performed. If none of them is black, then operation 2 can be performed on the four cells on both sides of this edge, followed by operation 1. Therefore, all three cells must be black. By induction, it can be concluded that all cells are black, which contradicts our assumption. Therefore, all the columns have exactly one black cell.

At this point, let the number of black cells in each column be . Either there are two black cells with a common edge in the first column, or there exists such that . From and , it follows that Using the same procedure as before, we can perform operations in the columns such that there are two black cells with a common edge in one of these columns, without affecting the two black cells with a common edge in the same row. Now, we vertically move the two black cells in the same row and horizontally move the two black cells in the same column until these four black cells “meet,” creating a square with at least 3 black cells. As discussed earlier, it is always possible to perform operation 1 after several operations 2, and thus satisfies the given condition.

Therefore, the minimum value of is .
Final answer
n^2 + n + 1

Techniques

Invariants / monovariantsColoring schemes, extremal argumentsPigeonhole principle