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 4 of 5: Count the remaining II-cells by rows and columns
In plain words

Rows and columns indexed 22 modulo 33 contribute the complementary count; their overlap is again the good II-cells.

∣C∪R∣=29n2−a,∣I∣=49n2−3a|C\cup R|=\tfrac29n^2-a,\quad |I|=\tfrac49n^2-3a
Detailed analysis

Let CC be the II-cells in columns 3s+23s+2, and RR the II-cells in rows 3r+23r+2. Each selected column and row is balanced, so ∣C∣=∣R∣=n2/9|C|=|R|=n^2/9; their intersection is the aa good II-cells. Thus ∣C∪R∣=2n2/9−a|C\cup R|=2n^2/9-a. The cells counted in exactly one diagonal family contribute 2n2/9−2a2n^2/9-2a, while the row/column union contributes 2n2/9−a2n^2/9-a, so the total number of II-cells is 4n2/9−3a4n^2/9-3a.