A ternary sequence is one whose terms all lie in the set $\{0, 1, 2\}$. Let $w$ be a length $n$ ternary sequence $(a_1,\ldots,a_n)$. Prove that $w$ can be extended leftwards and rightwards to a length $m=6n$ ternary sequence \[(d_1,\ldots,d_m) = (b_1,\ldots,b_p,a_1,\ldots,a_n,c_1,\ldots,c_q), \quad p,q\geqslant 0,\]containing no length $t > 2n$ palindromic subsequence. (A sequence is called palindromic if it reads the same rightwards and leftwards. A length $t$ subsequence of $(d_1,\ldots,d_m)$ is a sequence of the form $(d_{i_1},\ldots,d_{i_t})$, where $1\leqslant i_1<\cdots<i_t \leqslant m$.)
Problem
Source: 2020 RMM Shortlist C4
Tags: combinatorics, Sequence, RMM, RMM 2020, RMM Shortlist
19.02.2023 19:12
For any ternary word $v{}$, let $|v|_d$ denote the number of occurrences of digit $d{}$ in $v{}$, and let $|v|$ be the total number of digits in $v{}$. For convenience, write $|w| = n$, $|w|_0 = a$, $|w|_1 = b$, and $|w|_2 = c$. We may assume that $a\leqslant b\leqslant c$. We choose a partition $w = L_0L_2$ maximizing the value $\ell = 2|L_0|_0 + |L_2|_2$. In other words, $\ell$ is the maximal value of $2s + t$ where $0^s2^t$ is a subsequence in $w{}$. Similarly let $w = R_2R_0$ be a partition maximizing $r = |R_2|_2 + 2|R_0|_0$. Clearly, both $\ell$ and $r{}$ are at least $c{}$ but do not exceed $2a + c \leqslant n$. Now we are ready to define the words \[W_0=0^{2n-a}2^{2n-r}w2^{r-c}1^{2n-b}=PwQ\quad\text{and}\quad W_1=1^{2n-b}2^{\ell-c}w2^{2n-\ell}0^{2n-a}.\]It is readily checked that $|W_i|_0 = |W_i|_1 = |W_i|_2 = 2n$ and $|W_i| = 6n$. We show that one of the two words contains no palindromic subsequences (hereafter referred to as subpalindromes) of length $>2n$, whence the conclusion. Notice that any palindrome of length $k{}$ contains a subpalindrome of length $k-1$ (just remove one of the central digits). Thus it suffices to show that one of the words contains no subpalindrome of length $2n + 1$. Step 1. We first show that none of $W_0$ and $W_1$ contains such a subpalindrome starting (and hence ending) with $0{}$ or $1{}$. By symmetry, it suffices to deal with $W_0$. Choose any odd-length subpalindrpome $u{}$ in $W_0$ starting with $0{}$ or $1{}$. Assume first that $u{}$ starts with $0{}$; then $u{}$ is a subpalindrome of $Pw = 0^{2n-a}2^{2n-r}w$. Consider a central digit $d{}$ of $u{}$, and check its location in $Pw$. If $d{}$ is located in $0^{2n-a}$, then all digits of $u{}$ are zeroes, so $|u| \leqslant 2n$. If $d{}$ is located in $w{}$, then the right-hand half of $u{}$ (including $d{}$) contains at most $n{}$ digits, so $|u| \leqslant 2n - 1$. Finally, if $d{}$ is located in $2^{2n-r}$, then $u$ is of the form $0^x2^y2^z0^x$, where the last part $2^z0^x$ consists of the digits taken from $w{}$. Clearly, $y \leqslant 2n - r$. The definition of $r{}$ yields $z + 2x \leqslant r$; so $|u| = 2x + y + z \leqslant 2n$, as desired. A similar analysis works if $u{}$ starts with $1{}$. In this case, $u{}$ is a subword in $wQ = w2^{r-c}1^{2n-b}$. If the central digit $d{}$ is located in either $1^{2n-b}$ or $w{}$, the argument works verbatim. Finally, if $d{}$ is located in $2^{r-c}$, we expand $u = 0^x2^z2^y0^x$ and implement the estimates $x \leqslant a$, $z \leqslant c$, and $y \leqslant r - c \leqslant 2a$ to get $|u| = 2x + y + z \leqslant 4a + c < 2n$. Step 2. It remains to show that one of $W_0$ and $W_1$ contains no subpalindrome of length $2n + 1$ starting with $2{}$. Arguing indirectly, choose that long subpalindromes $u_0$ and $u_1$; notice that in fact they are subpalindromes in \[V_0=2^{2n-r}w2^{r-c}\quad\text{and}\quad V_1=2^{\ell-c}w2^{2n-\ell},\quad\text{respectively,}\]and their central digits necessarily lie in $w{}$, otherwise the subpalindrome would consist of $2{}$’s alone. We first analyse the location of $u_0$ in $V_0$. Clearly, it has the form $u_0=2^xv_02^y2^z$ where $2^x$ is a subword in $2^{2n-r}w$, $v_0$ starts and ends with $0{}$ or $1{}$ (hence $v_0$ is a subpalindrome in $w{}$), $2y$ is a part to the right of $v_0$ contained in $w{}$, and $2^z$ is contained in $2^{r-c}$; notice that $x = y + z$. Recall here the definitions of $L_0, L_2, R_2$, and $R_0$. Case 1: Assume that $v_0$ contains some digit in $R_0$; in particular, this yields $y \leqslant |R_0|_2$. In this case we show that $|u_0| \leqslant 2n$, reaching thus a contradiction. Let $d{}$ be the central digit in $v_0$ (and hence in $u_0$). We distinguish two subcases. Subcase 1.1: Assume that $d{}$ is contained in $R_2$; in particular, $|v_0|_0 \leqslant 2|R_2|_0$. Then we have \begin{align*}|u_0|&=|v_0|+2(y+z)= |v_0|_0+|v_0|_1+(|v_0|_2+y)+y+2z\leqslant 2|R_2|_0+b+c+|R_0|_2+2(r-c) \\ &=b-c+2|R_2|_0+|R_0|_2+2|R_2|_2+4|R_0|_0\leqslant b-c+4a+2c=4a+b+c\leqslant 2n.\end{align*}Subcase 1.2: Assume that $d{}$ is contained in $R_0$; this means that a half of the $2{}$’s present in $v_0$ are contained in $R_0$, so $|v_0|_2 \leqslant 2(|R_0|_2 - y)$. Then we have \begin{align*}|u_0|&=|v_0|_0+|v_0|_1+(2|v_0|_2+2y)+2z\leqslant a+b+2|R_0|_2+2(r-c) \\ &= (a+b-2c)+2|R_0|_2+2|R_2|_2+4|R_0|_0\leqslant (a+b-2c)+2c+4a\leqslant 2n.\end{align*}This settles Case 1. Similarly, expanding $u_1 = 2^{z'}2^{y'}v_12^{x'}$ we get that $|u_1| \leqslant 2n$ if $v_1$ contains some digit in $L_0$. The remaining case i Case 2: Assume that $v_0$ is contained in $R_2$, and $v_1$ is contained in $L_2$. In this case, we show that $|u_0| + |u_1| \leqslant 4n$, thus reaching a final contradiction. Notice that \begin{align*}|u_0|+|u_1|=|v_0|+|v_1|+2y+2y'+2z+2z'\leqslant (|v_0|+|v_1|+2y+2y')+2(r+\ell-2c). \qquad (\dagger)\end{align*}We start with an auxiliary estimate of the left subsum. Claim. If all occurrences of $v_0$ in $w{}$ are to the left of those of $v_1$, then \begin{align*}|v_0|+|v_1|+2y+2y'\leqslant a+b+4c\quad\text{and otherwise,}\quad |v_0|+|v_1|+2y+2y'\leqslant2a2b+3c.\end{align*}Proof. In the former case, notice that $|v_0|_i + |v_1|_i \leqslant |w|_i$, so \begin{align*}|v_0|+|v_1|+2y+2y'&\leqslant (|v_0|_0+|v_1|_0)+(|v_0|_1+|v_1|_1)+2(|v_0|_2+y)+2(|v_1|_2+y') \\ &\leqslant a+b+2c+2c=a+b+4c.\end{align*}In the latter case, notice that $y + y' \leqslant c$, so \[|v_0|+|v_1|+2y+2y'\leqslant (|v_0|+y)+(|v_1|+y)+(y+y')\leqslant 2n+c.\qquad \square\]Now we split into two subcases. Subcase 2.1: Assume that the subwords $R_2$ and $L_2$ overlap in $w{}$. This yields $|R_0|_0 + |L_0|_0 \leqslant a$, so \[r+\ell=|R_2|_2+|L_2|_2+2(|R_0|_0+|L_0|_0)\leqslant 2c+2a.\]Hence the claim along with $(\dagger)$ yields either $|u_0| + |u_1| \leqslant (a + b + 4c) + 4a \leqslant 4n$ or \[|u_0| + |u_1| \leqslant (2a + 2b + 3c) + 4a \leqslant 4n,\]as desired. Subcase 2.2: Assume that $R_2$ is contained in $L_0$; in particular, the first case in the claim holds. We have $|R_2|_2 + |L_2|_2 \leqslant c$, so \[r+\ell\leqslant (|R_2|_2+|L_2|_2)+2(|R_0|_0+|L_0|_0)\leqslant c+4a.\]Therefore, by the claim and $(\dagger)$ we get $|u_0| + |u_1| \leqslant (a + b + 4c) + 2(4a - c) = 9a + b + 2c \leqslant 4n$, as desired.