9

Ana and Banana are playing a game. First Ana picks a word, which is defined to be a nonempty sequence of capital English letters. (The word does not need to be a valid English word.) 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 wins no matter what value of $k$ Banana chooses? (Find all words such that Ana can pick at the start and always have a winning response regardless of the value of $k$ chosen by Banana.)

Remarks.

If Ana chooses "A", then for any $k$, Ana can give a word with exactly $k$ subsequences "AAA...A" ($k$ times). If Ana chooses "AB", then for any $k$, Ana can give a word with exactly $k$ subsequences "ABBB...B" ($k$ times).

If Ana chooses a string with no repetition at the end, say $X_1X_2X_3\cdots X_n$, where $X_{n-1}\neq X_n$, then Ana wins for any value of $k$ by supplying $$X_1X_2X_3\cdots X_{n-1}\underbrace{X_nX_n\cdots X_n}_{k\text{ terms}}\,.$$

If Ana chooses a string of length $n>1$ consisting of the same letter, she loses if Banana takes $k=2$ already.

PS: I didn't posted it AOPS since we only get solutions there .

Thanks in advance.

Batominovski
  • 49,629
Raheel
  • 1,597
  • 1
    Don't get your hopes up here. If you don't show your attempt, your thread can be closed, even when you are asking for hints. – Batominovski Jul 26 '20 at 17:21
  • 1
    @Batominovski: It's certainly possible, though I'm not sure that's such a great policy on an olympiad problem. – Brian Tung Jul 26 '20 at 17:22
  • 1
    @BrianTung I don't agree with this policy, but it is how it is. – Batominovski Jul 26 '20 at 17:22
  • Well, I tried some examples – Raheel Jul 26 '20 at 17:25
  • 2
    OP: Am I missing something? What if Ana's word is, say, AB, and to any challenge $k$ from Banana, Ana responds ABBBBB... with $k$ B's? Something that trivial can't be right, I suspect, so I must be misunderstanding the question. – Brian Tung Jul 26 '20 at 17:25
  • @Shubhangi: I reverted one of your edits; string literals are best not placed in MathJax, since the kerning is not good for words and it makes it somewhat harder to read, I think. – Brian Tung Jul 26 '20 at 17:27
  • 2
    If Anna chooses "T", and Bananna choosing $k$, then $TTTT....T$ ($k$ times) is winning? – YJT Jul 26 '20 at 17:28
  • @BrianTung I think the actual question is "Find all words such that Ana has a winning strategy." Notice the question: "Which word$\color{red}{\text{s}}$ [...]?" – Batominovski Jul 26 '20 at 17:31
  • Here is a hint: Anna can clearly win if she chooses A, can she win if she chooses AA? – cha21 Jul 26 '20 at 17:31
  • Maybe looking at the words Ana and Banana themselves.. :) – EDX Jul 26 '20 at 17:32
  • @Batominovski: Ahh, got it. I should have figured out that there was a request for complete characterization. I guess I'm not all the way awake yet... – Brian Tung Jul 26 '20 at 17:33
  • Hmm, I thought the answer had to do with the beginning or the ending of the sequence (that is, the first two letters cannot be the same and the last two characters cannot be the same). Apparently, "AABCC" is also a winning word. For each $k$, Ana can supply AABB...BBCC with exactly $k$ B's. Any string with a letter that is different from its neighbors (from both sides) is a winning word (e.g., AABBBBCBDD can be won by using AABBBBCBB...BBDD with $k$ B's before the final DD, or by AABBBBCC...CCBDD with $k$ C's). – Batominovski Jul 26 '20 at 17:52

1 Answers1

5

Hint (as requested by the OP). In combination with my last comment under your question, show that every word $X_1X_2\ldots X_n$ Ana can use to always win must have a letter that is not the same as its neighbors (from both sides). Prove also that, if this condition is not met, Banana wins with $k=2$.

Warning! If you do not wish to see the whole solution, do not move your mouse over the hidden portion below. A solution sketch is given there.

If Ana chooses the word $X_1X_2\ldots X_n$ such that, for some $i=1,2,\ldots,n$, $X_i$ is different from both neighbors, then for any positive integer $k$, Ana wins by responding with $$X_1X_2\cdots X_{i-1}\underbrace{X_iX_i\cdots X_iX_i}_{k\text{ times}}X_{i+1}\cdots X_{n-1}X_n\,.$$ For the other direction, suppose that Ana chooses a word $X_1X_2\cdots X_n$ such that, for every index $i$, either $X_i=X_{i-1}$ or $X_i=X_{i+1}$. Banana responds by picking $k=2$.
We shall prove that any string $Y_1Y_2\cdots Y_m$ that contains at least two copies of $X_1X_2\cdots X_n$ as a substring must contain more than $2$ copies of $X_1X_2\cdots X_n$. For $i=1,2,\ldots,n$, let $a_i$ denote the smallest index $j\in \{1,2,\ldots,m\}$ such that there exists a substring of $Y_1Y_2\ldots Y_m$ where $X_i$ is taken from the position $Y_j$. We also let $b_i$ to be the largest index $j\in\{1,2,\ldots,m\}$ such that there exists a substring of $Y_1Y_2\ldots Y_m$ where $X_i$ is taken from the position $Y_j$.
Divide $X_1X_2\ldots X_n$ into $Z_1Z_2\cdots Z_r$, where each cluster $Z_s$ is a sequence of the same letter such that consecutive clusters $Z_s$ and $Z_{s+1}$ do not share a letter. Define $z_s$ and $z'_s$ to be the first and the last positions of the letters in $Z_s$ (i.e., their positions in $X_1X_2\cdots X_n$). Show that, for some $s=1,2,\ldots,r$, there are at least $z'_s-z_s+2$ indices $\ell$ such that $a_{z_s}\leq \ell\leq b_{z'_s}$ and $Y_\ell=X_{z_s}$. Therefore, there are at least $$\binom{{z'_s}-{z_s}+2}{z'_s-z_s+1}\geq z'_s-z_s+2\geq 3$$ substrings of $Y_1Y_2\cdots Y_m$ that equal $X_1X_2\cdots X_n$.

ShBh
  • 6,054
Batominovski
  • 49,629
  • I wonder if, in the case that Banana can win, do there exist infinitely many values of $k$ that Banana can pick and win? – Batominovski Jul 26 '20 at 19:31
  • Thanks a lot , I got it . – Raheel Jul 27 '20 at 02:06
  • @Batominovski great proof . Well, I am new to MSE , so just asking , how did you hide the solution ? – Sunaina Pati Jul 27 '20 at 02:22
  • @Shubhangi Use the command >!. However, you cannot separate paragraphs when using this command. If you want to separate paragraphs, use <br>. You can click the button "edit" under my answer to see how I wrote my answer. – Batominovski Jul 27 '20 at 08:28