MathLabs

Problem 2

Find all integers nn for which each cell of an n×nn\times n table can be filled with one of the letters II, MM, and OO in such a way that: in each row and each column, one third of the entries are II, one third are MM, and one third are OO; and in any diagonal, if the number of entries on the diagonal is a multiple of three, then one third of the entries on that diagonal are II, one third are MM, and one third are OO. (Note that an n×nn\times n table has 4n−24n-2 diagonals in total, in both directions.)
Step 2 of 5: Necessity: mark the good cells
In plain words

The row and column conditions force 3∣n3\mid n. The cells with both coordinates congruent to 22 modulo 33 are the centers that can be counted from two directions.

n=3k,G={(3r+2,3s+2):0≤r,s<k}n=3k,\quad G=\{(3r+2,3s+2):0\le r,s<k\}
Detailed analysis

Each row contains one third of each letter, so 3∣n3\mid n; write n=3kn=3k. Call a cell (3r+2,3s+2)(3r+2,3s+2) good. Let aa be the number of good cells containing II. Every good cell lies on one diagonal of each direction, and both diagonal lengths are multiples of 33.