2019 USAJMO Problems/Problem 1


There are $a+b$ bowls arranged in a row, numbered $1$ through $a+b$, where $a$ and $b$ are given positive integers. Initially, each of the first $a$ bowls contains an apple, and each of the last $b$ bowls contains a pear.

A legal move consists of moving an apple from bowl $i$ to bowl $i+1$ and a pear from bowl $j$ to bowl $j-1$, provided that the difference $i-j$ is even. We permit multiple fruits in the same bowl at the same time. The goal is to end up with the first $b$ bowls each containing a pear and the last $a$ bowls each containing an apple. Show that this is possible if and only if the product $ab$ is even.


Claim: If $a$ and $b$ are both odd, then the end goal of achieving $b$ pears followed by $a$ apples is impossible.

Proof: Let $A_1$ and $P_1$ denote the number of apples and the number of pears in odd-numbered positions, respectively. We show that $A_1 - P_1$ is invariant. Notice that if $i$ and $j$ are odd, then $A_1$ and $P_1$ both decrease by 1, as one apple and one pear are both moved from odd-numbered positions to even-numbered positions. If $i$ and $j$ are even, then $A_1$ and $P_1$ both increase by 1.

Because the starting configuration $aa\ldots ab\ldots b$ has $\left\lfloor \frac{a}{2} \right\rfloor + 1$ odd-numbered apples and $\left\lfloor \frac{b}{2} \right\rfloor$ odd-numbered pears, the initial value of $A_1 - P_1$ is $\left\lfloor \frac{a}{2} \right\rfloor - \left\lfloor \frac{b}{2} \right\rfloor + 1$. But the desired ending configuration has $\left\lfloor \frac{b}{2}\right\rfloor + 1$ odd-numbered pears and $\left\lfloor \frac{a}{2} \right\rfloor$ odd-numbered apples, so $A_1 - P_1 = \left\lfloor \frac{a}{2} \right\rfloor - \left\lfloor \frac{b}{2} \right\rfloor - 1$. As $A_1 - P_1$ is invariant, it is impossible to attain the desired ending configuration. $\blacksquare$

Claim: If at least one of $a$ and $b$ is even, then the end goal of achieving $b$ pears followed by $a$ apples is possible.

Proof: Without loss of generality, assume $a$ is even. If only $b$ is even, then we can number the bowls in reverse, and swap apples with pears. We use two inductive arguments to show that $(a,b) = (2,b)$ is achievable for all $b\ge 1$, then to show that $(a,b)$ is achievable for all even $a$ and all $b\ge 1$.

Base case: $(a,b) = (2,1)$. Then we can easily achieve the ending configuration in two moves, by moving the apple in bowl #1 and the pear in bowl #3 so that everything is in bowl #2, then finishing the next move.

Inductive step: suppose that for $a \ge 2$ (even) apples and $b \ge 1$ pears, that with $a$ apples and $b$ pears, the ending configuration is achievable. We will show two things: i) achievable with $a$ apples and $b+1$ pears, and ii) achievable with $a+2$ apples and $b$ pears.

i) Apply the process on the $a$ apples and first $b$ pairs to get a configuration $bb\ldots ba\ldots ab$. Now we will "swap" the leftmost apple with the last pear by repeatedly applying the move on just these two fruits (as $a$ is even, the difference $i-j$ is even). This gives a solution for $a$ apples and $b+1$ pears. In particular, this shows that $(a,b) = (2,b)$ for all $b\ge 1$ is achievable.

ii) To show $(a+2, b)$ is achievable, given that $(a,b)$ is achievable, apply the process on the last $a$ apples and $b$ pears to get the configuration $aabbb\ldots baaa\ldots a$. Then, because we have shown that 2 apples and $b$ pears is achievable in i), we can now reverse the first two apples and $b$ pears.

Thus for $ab$ even, the desired ending configuration is achievable. $\blacksquare$

Combining the above two claims, we see that this is possible if and only if $ab$ is even. -scrabbler94

Solution 2

"If" part: Note that two opposite fruits can be switched if they have even distance. If one of $a$, $b$ is odd and the other is even, then switch $1$ with $a+b$, $2$ with $a+b-1$, $3$ with $a+b-2$... until all of one fruit is switched. If both are even, then if $a>b$, then switch $1$ with $a+1$, $2$ with $a+2$, $3$ with $a+3$... until all of one fruit is switched; if $a<b$ then switch $a$ with $a+b$, $a-1$ with $a+b-1$, $a-2$ with $a+b-2$... until all of one fruit is switched. Each of these processes achieve the end goal.

"Only if" part: Assign each apple a value of $1$ and each pear a value of $-1$. At any given point in time, let $E$ be the sum of the values of the fruit in even-numbered bowls. Because $a$ and $b$ both are odd, at the beginning there are $\frac{a-1}{2}$ apples in even bowls and $\frac{b+1}{2}$ pears in even bowls, so at the beginning $E=\frac{a-b}{2}-1$. After the end goal is achieved, there are $\frac{a+1}{2}$ apples in even bowls and $\frac{b-1}{2}$ pears in even bowls, so after the end goal is achieved $E=\frac{a-b}{2}+1$. However, because two opposite fruits must have the same parity to move and will be the same parity after they move, we see that $E$ is invariant, which is a contradiction; hence, it is impossible for the end goal to be reached if $ab$ is odd.


Solution 3

We define a cycle to be when $2$ fruits in bowls $i$ and $j$ are swapped with eachother, provided that bowls $i$ contains an apple, bowl $j$ contains a pear, and the difference $i-j$ is even.

We claim that a cycle consists of only the valid moves described in the problem statement. Proof: We can move the apple and pear one step at a time to eventually reach the other's bowl(i.e. the apple moves to $i+1$ and the pear moves to bowl $j-1$ at the beginning) using only valid moves. By a simple parity argument(if $k$ moves have already been done, $i+k-(j-k)=i+j+2k=0+2k=2k=0 \textbf{mod 2}$), these moves are always valid, so we are done. $\blacksquare$

We now split the "if" part of this proof into cases based on the parities of $a$ and $b$.

Case 1: $a$ even, $b$ odd In this case we can simply cycle the fruit in bowl $k+1$ with the fruit in bowl $a+b-k$ for all integer $k$ in the range $[0,b-1]$ to achieve our desired goal. The difference $a+b-k-k-1=a+b-1$ is even, so the move is valid.

Case 2: $b$ even, $a$ odd Using the same cycle as the previous case works here.

Case 3: $a$ even, $b$ even Here, we can cycle the fruits in bowls $k$ and $a+b-k$ for all integer $k$ in the range $[1,b]$. Then, we finish by cycling the fruits in bowls $a$ and $a+b$. These are both valid moves by similar parity arguments as done in Case 1.

Since we have exhausted all possible cases for the "if" part of this proof, we have completed the if part. We will proceed with the "only if" part.

We let the number of apples in odd positions be $A_1$, and the number of pears in odd positions be $A_2$. Obviously $A_1-A_2$ is invariant when using valid moves only. We can now use proof by contradiction(i.e. showing that this invariant does not occur when $a, b \equiv 1 \text{ mod } 2$ and our desired goal is achieved) to find that we have that $0=2$, which is obviously false, so we have completed the proof for the "only if" part.

We are now done, since we have completed our proofs for the "if" and "only if" parts. $\blacksquare$


Solution 4

Begin by defining a $\textit{swap}$ as a set of $i - j$ legal moves taking an apple in $i \rightarrow j$ and the pear in $j \rightarrow i$. Now we begin by proving if $ab$ is even, then the final configuration is possible.

WLOG let $b$ be even. Then there are two cases to consider. $a < b, a \ge b$ to provide valid constructions for. In the first case, consider the apple/pear pairs $(1,b+1), (2, b+2), \dots, (i, b+i), \dots, (a, b+a)$ and swap them. This results in the transformation, \begin{align*} \underbrace{AA \cdots A}_{\text{a apples}}& \underbrace{PP \cdots P}_{\text{b pears}} \\ \underbrace{PP \cdots P}_{\text{a pears}}& \underbrace{PP \cdots P}_{\text{b-a pears}} \underbrace{AA \cdots A}_{\text{a apples}}  \\ \underbrace{PP \cdots P}_{\text{b pears}} &\underbrace{AA \cdots A}_{\text{a apples}}  \\ \end{align*} as desired.

Now consider the case where $a \ge b$. Also consider the pairing, $(a-b + 1, a + 1), (a - b + 2, a+2), \dots, (a - b + i, a+i), \dots, (a, a + b)$ and swap them. This results in the transformation, \begin{align*} \underbrace{AA \cdots A}_{\text{a apples}} & \underbrace{PP \cdots P}_{\text{b pears}} \\ \underbrace{AA \cdots A}_{\text{a-b apples}}\underbrace{PP \cdots P}_{\text{b pears}}& \underbrace{AA \cdots A}_{\text{b apples}}. \end{align*} Now just consider the leftmost $a$ bowls. There are $a-b$ apples, and then $b$ pears. We have effectively reduced $(a,b) \rightarrow (a-b, b)$. Reducing in this fashion recursively will lead to $(a \pmod{b}, b)$ which can be constructed with the $a<b$ case. This finishes the construction for $a \ge b$.

Now assume $ab,a,b$ are odd. FTSOC, let this case satisfy the claim. Then, for each apple, define it's $\textit{position}$ as the sum of the distance from it to all other pairs. So for apple in bowl $i \le a$ originally, the position of $i$ is $\sum_{j = a+1}^{b} j - i .$

Every time a legal move is made, the position of the apple decreases by $b - 1 + 2 = b+1$ (from the $b-1$ pears not part of the move and the decrease in $2$ by the corresponding pear). Also note that there needs to be exactly $ab$ moves in order to attain the final configurations. So the difference in sum of positions of the apples at the beginning and end is $ab(b+1)$. Mathematically, \begin{align*} \sum_{i = 1}^{a} \sum_{j = a+1}^{a+b} j - i  - \sum_{i = b + 1}^{b+a} \sum_{j = 1}^{b} j - i &= ab(b+1)\\ (\frac{ab(2a + b + 1)}{2} - \frac{ab(a + 1)}{2}) - (\frac{ab(b+1)}{2} - \frac{ab(a + 2b + 1)}{2}) &=  \\ ab(a+b) &= ab(b+1) \\ a &= 1. \end{align*} A symmetric argument for the position of pears gives $b = 1$. Clearly the $a=b=1$ does not have a solution, therefore we have contradiction. $\square$

~ Aaryabhatta1

The problems on this page are copyrighted by the Mathematical Association of America's American Mathematics Competitions. AMC logo.png

See also

2019 USAJMO (ProblemsResources)
First Problem Followed by
Problem 2
1 2 3 4 5 6
All USAJMO Problems and Solutions