# Difference between revisions of "2016 USAMO Problems/Problem 6"

## Problem

Integers $n$ and $k$ are given, with $n\ge k\ge 2.$ You play the following game against an evil wizard.

The wizard has $2n$ cards; for each $i = 1, ..., n,$ there are two cards labeled $i.$ Initially, the wizard places all cards face down in a row, in unknown order.

You may repeatedly make moves of the following form: you point to any $k$ of the cards. The wizard then turns those cards face up. If any two of the cards match, the game is over and you win. Otherwise, you must look away, while the wizard arbitrarily permutes the $k$ chosen cards and turns them back face-down. Then, it is your turn again.

We say this game is $\textit{winnable}$ if there exist some positive integer $m$ and some strategy that is guaranteed to win in at most $m$ moves, no matter how the wizard responds.

For which values of $n$ and $k$ is the game winnable?

## Solution

We first prove that the game is winnable whenever $n > k$ by demonstrating a winning strategy in this case.

On the $i$th move, choose the $k$ cards in positions $i$ through $i+k-1.$ Assuming that you do not win on any earlier move, repeat this for $1\le i \le 2n-k+1.$

Assume that you did not win on any of the first $2n-k+1$ moves, as described above. Let $j$ be an integer such that $1\le j\le 2n-k.$ On the $j$th move, the wizard revealed the cards in positions $j$ through $j+k-1,$ so you know the labels of all of these cards (just not necessarily in the right order). Then, on the $(j+1)$th move, the wizard revealed the cards in positions $j+1$ through $j+k,$ which means that you get to see all of the cards that were moved to positions $j+1$ through $j+k.$ This means that you can uniquely determine the label on card $j,$ since you knew all of the labels from $j$ through $j+k-1,$ and the card in position $j$ could not have moved anywhere else since your last move.

It follows that, after the sequence of $2n-k+1$ moves described above, you know the labels on the first $2n-k$ cards. Since $n > k,$ we have $2n-k \ge n+1,$ so there must be a pair of cards with matching labels in this group of $2n-k$ cards, by the Pigeonhole Principle. On your next move, you can pick a group of $k$ cards that includes that pair of matching cards, and you win.

We have created a strategy that is guaranteed to win in at most $m = 2n-k+2$ moves. Thus, the game is winnable for all $n > k.$

We now prove that the game is not winnable if $n=k.$ We will say that the game is in a state $S$ if your knowledge about the card labels is of the following form:

There exists a group of $n$ cards for which you know that those $n$ cards have all of the labels $1, 2, ..., n$ (i.e. you know that they have all distinct labels) in some order, but you know nothing about which of those $n$ cards have which labels. (Call this group of cards Group $A.$)

Suppose that the game is in such a state $S.$ We will now show that, regardless of your next move, you cannot guarantee victory or an escape from state $S.$

Clearly, the $n$ cards that are not in Group $A$ must also have all of the labels $1, 2, ..., n.$ (You might know something about which cards have which labels, or you might not.) Call this other collection of cards Group $B.$

If, on the next move, you pick all of the cards from Group $A$ or all of the cards from Group $B,$ then you clearly will not get a matching pair. The wizard will then arbitrarily permute those cards. Thus, for those $n$ chosen cards, you know their labels are all distinct, but you know nothing about which cards have which labels. Thus, you are back in state $S.$

Now, suppose you pick $x$ cards from Group $A$ and $n-x$ cards from Group $B,$ where $x$ is an integer and $1\le x\le n-1.$ Then, the cards chosen from Group $B$ will form a set of labels $P\subset Z_n,$ where $Z_n = \left\{ {1, 2, ..., n} \right\}$ and $|P| = n-x.$ However, you know nothing about which cards in Group $A$ have which labels. Thus, there is no way for you to prevent the $x$ cards from Group $A$ to form the exact set of labels $Q = Z_n\setminus P.$ In such a case, there will be no matching cards, so you will not win. Furthermore, the wizard will then arbitrarily permute these $n$ cards, so you will know that they have all $n$ distinct labels, but you will know nothing about which cards have which labels. Therefore, you are again in state $S.$

We have covered all cases, so it follows that, once you enter state $S,$ you cannot guarantee escape from state $S$ or victory.

Now, look at the very first move you make. Obviously, you cannot guarantee victory on the first move, as you know nothing about which cards have which labels. Assuming that you do not win on the first move, the $n$ cards you chose have all distinct labels. The wizard then permutes the $n$ cards you chose, so you now know that those $n$ cards have all distinct labels but know nothing about which cards have which labels. Therefore, if you do not win on your first move, then the game enters state $S,$ and we have already proven that you cannot guarantee victory from this point.

We therefore conclude that the game is not winnable if $n=k.$ We proved earlier that the game is winnable if $n>k,$ so the game is winnable if and only if $n>k\ge 2.$

## Solution 2

We claim that the game is winnable if and only if $n>k$. Suppose after the first step, the cards $1$ to $n$ are shuffled around. Notice that we have $n$ cards that we don't know the position of (which are all cards from $1$ to $n$). Now, suppose we pick $p$ known cards. Note that the $p$ cards are all different(since the known cards are the cards from $1$ to $n$), and there is still a possibility that the other cards from the unknown cards complement and cause $1$ to $n$. Therefore, we are in the same state as before, and the game is unwinnable.

Now, suppose $n>k$. Denote the ith card counting from the left. We pick cards $1$ to $k$, keeping track of the set of values of the cards. Then, we pick cards $2$ to $k+1$, adding the value of the $k+1$th card into the set of value of cards. We keep doing this, until we pick cards $2n-k$ to $2n-1$, at which point we know the exact number on the $2n$th card. Now, we go back to $1$ through $k$, and repeat this process, until we reveal the $2n-1$th card(unless we win during the process). This process terminates only when there are less or equal to $k$ cards that we don't know the exact numbers on or if we somehow win, clearly, as otherwise we're still revealing new information by picking cards from $1$ through $k$. Note that we now know the exact values on $2n-k$ of the cards. By the Pigeonhole Principle, since $k, $2$ of them are the same, and we pick those $2$ cards and $k-2$ other random cards and we win.