Olympiad Maths Prep

Track / Stage 10 / 24 of 40 #1984 of 2000

Problem 1984

Hardest shortlist tier
Combinatorics Difficulty 9.3 Prove it USA TST · United States

Let mm and nn be fixed positive integers. Tsvety and Freyja play a game on an infinite grid of unit square cells. Tsvety has secretly written a real number inside of each cell so that the sum of the numbers within every rectangle of size either m×nm \times n or n×mn \times m is zero. Freyja wants to learn all of these numbers.

One by one, Freyja asks Tsvety about some cell in the grid, and Tsvety truthfully reveals what number is written in it. Freyja wins if, at any point, Freyja can simultaneously deduce the number written in every cell of the entire infinite grid. (If this never occurs, Freyja has lost the game and Tsvety wins.)

In terms of mm and nn, find the smallest number of questions that Freyja must ask to win, or show that no finite number of questions can suffice.

This one wants a proof. Work it on paper, read the official solution, then mark yourself honestly — the ladder only means something if the record is true.

Official solution

The answer is the following:
* If gcd(m,n)>1\gcd(m, n) > 1, then Freyja cannot win.
* If gcd(m,n)=1\gcd(m, n) = 1, then Freyja can win in a minimum of (m1)2+(n1)2(m-1)^2 + (n-1)^2 questions.

First, we dispose of the case where gcd(m,n)>1\gcd(m, n) > 1. Write d=gcd(m,n)d = \gcd(m, n). The idea is that any labeling where each 1×d1 \times d rectangle has sum zero is valid. Thus, to learn the labeling, Freyja must ask at least one question in every row, which is clearly not possible in a finite number of questions.

Now suppose gcd(m,n)=1\gcd(m, n) = 1. We split the proof into two halves.

¶ Lower bound
Clearly, any labeling where each m×1m \times 1 and 1×m1 \times m rectangle has sum zero is valid. These labelings form a vector space with dimension (m1)2(m-1)^2, by inspection. (Set the values in an (m1)×(m1)(m-1) \times (m-1) square arbitrarily and every other value is uniquely determined.)

Similarly, labelings where each n×1n \times 1 and 1×n1 \times n rectangle have sum zero are also valid, and have dimension (n1)2(n-1)^2.

It is also easy to see that no labeling other than the all-zero labeling belongs to both categories; labelings in the first space are periodic in both directions with period mm, while labelings in the second space are periodic in both directions with period nn; and hence any labeling in both categories must be constant, ergo all-zero.

Taking sums of these labelings gives a space of valid labelings of dimension (m1)2+(n1)2(m-1)^2 + (n-1)^2. Thus, Freyja needs at least (m1)2+(n1)2(m-1)^2 + (n-1)^2 questions to win.

¶ Proof of upper bound using generating functions, by Ankan Bhattacharya
We prove:

Claim (Periodicity) — Any valid labeling is doubly periodic with period mnmn.

*Proof.* By Chicken McNugget, there exists NN such that NN and N+1N+1 are both nonnegative integer linear combinations of mm and nn.

Then both mn×Nmn \times N and mn×(N+1)mn \times (N + 1) rectangles have zero sum, so mn×1mn \times 1 rectangles have zero sum. This implies that any two cells with a vertical displacement of mnmn are equal; similarly for horizontal displacements. \square

With that in mind, consider a valid labeling. It naturally corresponds to a generating function
f(x,y)=a=0mn1b=0mn1ca,bxayb f(x, y) = \sum_{a=0}^{mn-1} \sum_{b=0}^{mn-1} c_{a,b} x^a y^b
where ca,bc_{a,b} is the number in (a,b)(a, b).

The generating function corresponding to sums over n×mn \times m rectangles is
f(x,y)(1+x++xm1)(1+y++yn1)=f(x,y)xm1x1yn1y1. f(x, y)(1 + x + \cdots + x^{m-1})(1 + y + \cdots + y^{n-1}) = f(x, y) \cdot \frac{x^m - 1}{x - 1} \cdot \frac{y^n - 1}{y - 1}.
Similarly, the one for m×nm \times n rectangles is
f(x,y)xn1x1ym1y1. f(x, y) \cdot \frac{x^n - 1}{x - 1} \cdot \frac{y^m - 1}{y - 1}.
Thus, the constraints for ff to be valid are equivalent to
f(x,y)xm1x1yn1y1andf(x,y)xn1x1ym1y1 f(x, y) \cdot \frac{x^m - 1}{x - 1} \cdot \frac{y^n - 1}{y - 1} \quad \text{and} \quad f(x, y) \cdot \frac{x^n - 1}{x - 1} \cdot \frac{y^m - 1}{y - 1}
being zero when reduced modulo xmn1x^{mn} - 1 and ymn1y^{mn} - 1, or, letting ω=exp(2πi/m)\omega = \exp(2\pi i/m), both terms being zero when powers of ω\omega are plugged in.

To restate the constraints one final time, we need
f(ωa,ωb)ωam1ωa1ωbn1ωb1=f(ωa,ωb)ωan1ωa1ωbm1ωb1=0 f(\omega^a, \omega^b) \cdot \frac{\omega^{am} - 1}{\omega^a - 1} \cdot \frac{\omega^{bn} - 1}{\omega^b - 1} = f(\omega^a, \omega^b) \cdot \frac{\omega^{an} - 1}{\omega^a - 1} \cdot \frac{\omega^{bm} - 1}{\omega^b - 1} = 0
for all a,b{0,,mn1}a, b \in \{0, \dots, mn - 1\}.

This implies f(ωa,ωb)=0f(\omega^a, \omega^b) = 0 for most choices of (a,b)(a, b). If it does not, we need
ωam1ωa1ωbn1ωb1=ωan1ωa1ωbm1ωb1=0. \frac{\omega^{am} - 1}{\omega^a - 1} \cdot \frac{\omega^{bn} - 1}{\omega^b - 1} = \frac{\omega^{an} - 1}{\omega^a - 1} \cdot \frac{\omega^{bm} - 1}{\omega^b - 1} = 0.
This happens when (at least) one fraction in either product is zero.
* If the first fraction is zero, then either nan \mid a and a>0a > 0, or mbm \mid b and b>0b > 0.
* If the second fraction is zero, then either mam \mid a and a>0a > 0, or nbn \mid b and b>0b > 0.

If the first condition holds in both cases, then mnamn \mid a, but 0<a<mn0 < a < mn, a contradiction. Thus if nan \mid a, then we must have nbn \mid b, and similarly if mam \mid a then mbm \mid b.

The former case happens (m1)2(m - 1)^2 times, and the latter case happens (n1)2(n - 1)^2 times. Thus, at most (m1)2+(n1)2(m - 1)^2 + (n - 1)^2 values of f(ωa,ωb)f(\omega^a, \omega^b) are nonzero. It follows that the dimension of the space of valid labelings is at most (m1)2+(n1)2(m - 1)^2 + (n - 1)^2, as desired.

Let Freyja ask about all cells (x,y)(x, y) in the two squares
S1=[1,m1]×[1,m1]S2=[m,m+n2]×[1,n1]. \begin{aligned} S_1 &= [1, m-1] \times [1, m-1] \\ S_2 &= [m, m+n-2] \times [1, n-1]. \end{aligned}

In the beginning, one by one, Freyja determines all values inside of the rectangle Q:=[1,m1]×[m,n1]Q := [1, m-1] \times [m, n-1]. To that end, on each step she considers some rectangle with mm rows and nn columns such that its top left corner is in QQ and all of the other values in it have been determined already. In this way, Freyja uncovers all of QQ, starting with its lower right corner and then proceeding upwards and to the left.

Thus Freyja can learn all numbers inside of the rectangle
R:=[1,m+n2]×[1,n1]=QS1S2. R := [1, m+n-2] \times [1, n-1] = Q \cup S_1 \cup S_2.

See the figure below for an illustration for (m,n)=(5,8)(m, n) = (5, 8). The first cell of QQ is uncovered using the dotted green rectangle.
Figure 1

We need one lemma:
Lemma
Let mm and nn be positive integers with gcd(m,n)=1\gcd(m, n) = 1. Consider an unknown sequence of real numbers z1,z2,,zsz_1, z_2, \dots, z_s with sm+n2s \ge m+n-2. Suppose that we know the sums of all contiguous blocks of size either mm or nn in this sequence. Then we can determine all individual entries in the sequence as well.

*Proof.* By induction on m+nm+n. Suppose, without loss of generality, that mnm \le n. Our base case is m=1m=1, which is clear. For the induction step, set =nm\ell = n-m. Each contiguous block of size \ell within z1,z2,,zsnz_1, z_2, \dots, z_{s-n} is the difference of two contiguous blocks of sizes mm and nn within the original sequence. By the induction hypothesis for \ell and mm, it follows that we can determine all of z1,z2,,zsnz_1, z_2, \dots, z_{s-n}. Then we determine the remaining ziz_i as well, one by one, in order from left to right, by examining on each step an appropriate contiguous block of size mm. \square

Let TT be the rectangle [1,m+n2]×{n}[1, m+n-2] \times \{n\}. By looking at appropriate rectangles of sizes m×nm \times n and n×mn \times m such that their top row is contained within TT and all of their other rows are contained within RR, Freyja can learn the sums of all contiguous blocks of values of sizes mm and nn within TT. By the Lemma, it follows that Freyja can uncover all of TT.

In this way, with the help of the Lemma, Freyja can extend her rectangular area of knowledge both upwards and downwards. Once its height reaches m+n2m+n-2, by the same method she will be able to extend it to the left and right as well. This allows Freyja to determine all values in the grid. Therefore, (m1)2+(n1)2(m-1)^2 + (n-1)^2 questions are indeed sufficient.

Source: MathNet, licensed CC-BY-4.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.