Source: TSTST-2017-P2
Category: Operations and Strategies

Problem:
Ana and Banana are playing a game. First Ana picks a word, which is defined to be a nonempty sequence of capital English letters. Then Banana picks a nonnegative integer $k$ and challenges Ana to supply a word with exactly $k$ subsequences which are equal to Ana's word. Ana wins if she is able to supply such a word, otherwise she loses. For example, if Ana picks the word “TST”, and Banana chooses $k = 4$, then Ana can supply the word “TSTST” which has $4$ subsequences which are equal to Ana's word. Which words can Ana pick so that she can win no matter what value of $k$ Banana chooses?

Solution:
First we introduce some notation. Define a *block* of letters to be a maximal contiguous subsequence of consecutive identical letters. For example, the word $AABBBCAAA$ has four blocks, namely $AA$, $BBB$, $C$, and $AAA$. Throughout the solution, we fix the word $A$ that Ana picks, and introduce the following notation for its $m$ blocks: 
$$A = A_1 A_2 \dots A_m = \underbrace{a_1 \dots a_1}_{x_1} \underbrace{a_2 \dots a_2}_{x_2} \dots \underbrace{a_m \dots a_m}_{x_m}.$$ 
A *rainbow* will be defined as a subsequence equal to Ana's initial word $A$ (meaning Ana seeks words with exactly $k$ rainbows). For brevity, let $A_i = \underbrace{a_i \dots a_i}_{x_i}$, so $A = A_1 \dots A_m$.

We prove two claims that resolve the problem.

**Claim 1:** If $x_i = 1$ for some $i$, then for any $k \ge 1$, the word 
$$W = A_1 \dots A_{i-1} \underbrace{a_i \dots a_i}_{k} A_{i+1} \dots A_m$$ 
obtained by repeating the $i$th letter $k$ times has exactly $k$ rainbows.

*Proof:* Obviously there are at least $\binom{k}{k-1}=k$ rainbows, obtained by deleting $k-1$ choices of the letter $a_i$ in the repeated block. We show they are the only ones. Given a rainbow, consider the location of this singleton block in $W$. It cannot occur within the first $|A_1| + \dots + |A_{i-1}|$ letters, nor can it occur within the final $|A_{i+1}| + \dots + |A_m|$ letters. So it must appear in the $i$th block of $W$. That implies that all the other $a_i$'s in the $i$th block of $W$ must be deleted, as desired.

**Claim 2:** If $x_i \ge 2$ for all $i$, then no word $W$ has exactly two rainbows.

*Proof:* We prove that if there are two rainbows of $W$, then we can construct at least three rainbows. Let $W = w_1 \dots w_n$ and consider two rainbows of $W$. Since they are not the same, there must be a block $A_p$ of the rainbow, of length $\ell \ge 2$, which does not occupy the same locations in $W$. Assume the first rainbow uses $w_{i_1}, \dots, w_{i_\ell}$ for this block and the second rainbow uses $w_{j_1}, \dots, w_{j_\ell}$ for this block. Then among the letters $w_q$ for $\min(i_1, j_1) \le q \le \max(i_\ell, j_\ell)$, there must be at least $\ell+1$ copies of the letter $a_p$. Moreover, given a choice of $\ell$ copies of the letter $a_p$ in this range, one can complete the subsequence to a rainbow. So the number of rainbows is at least $\binom{\ell+1}{\ell} \ge \ell+1$. Since $\ell \ge 2$, this proves $W$ has at least three rainbows.

In summary, Ana wins if and only if $x_i = 1$ for some $i$, since she can duplicate the isolated letter $k$ times; but if $x_i \ge 2$ for all $i$ then Banana only needs to supply $k = 2$.

Answer: Ana wins if and only if at least one letter appears exactly once in her word.

Grading guidelines:
(Partial) 1. Proved the sufficiency direction: if Ana’s word contains a letter that occurs exactly once (equivalently, some block has length 1), then for any k one can repeat that letter k times in the supplied word and obtain exactly k subsequences equal to Ana’s word. 2. Proved a usable obstruction when every letter occurs at least twice (e.g. every block has length ≥2): showed that Banana can choose a specific small k (typically k=2) that cannot be realized, by arguing that having at least two target subsequences forces the existence of a third. 3. Introduced a correct block/runs decomposition of Ana’s word and used it to relate different embeddings of the word as a subsequence to a lower bound on the number of subsequences. (Almost) 1. Correctly identified the winning criterion (“Ana wins iff at least one letter appears exactly once”), and proved the construction for all k, but did not fully justify uniqueness of the counted k subsequences (e.g. did not rule out extra subsequences using the repeated block in a different way). 2. Proved the necessity direction for the case “all blocks have length ≥2” by showing ‘2 subsequences ⇒ at least 3’, but left a localized gap in the combinatorial argument (e.g. why a shifted block forces at least ℓ+1 choices, or why any such choice extends to a full subsequence). 3. Solution establishes both directions with the right main ideas, but contains a minor counting or boundary-case slip (such as k=0 or k=1 not explicitly handled) that does not undermine the overall structure.