Maths Olympiad Prep

Library / /9 of 11

Combinatorics Difficulty 7.1 National Olympiad, round 2 Prove it New Zealand

Problem:
A sequence of AAs and BBs is called antipalindromic if writing it backwards, then turning all the AAs into BBs and vice versa, produces the original sequence. For example ABBAABA B B A A B is antipalindromic. For any sequence of AAs and BBs we define the cost of the sequence to be the product of the positions of the AAs. For example, the string ABBAABA B B A A B has cost 145=201\cdot 4\cdot 5 = 20. Find the sum of the costs of all antipalindromic sequences of length 2020.

Solutions — 3

Solution 1

Solution:
For each integer 0k10090\leq k\leq 1009 define a kk-pal to be any sequence of 2020 AAs and BBs, where the first kk terms are BB, the last kk terms are BB, and the middle (20202k)(2020 - 2k) terms form an antipalindromic sequence.

Now for any kk, define f(k)f(k) to be sum of the costs of all kk-pals. Note that any kk-pal can be created from a (k+1)(k + 1)-pal by either
- (A) replacing the BB in position (k+1)(k + 1) with an AA, or
- (B) replacing the BB in position (2021k)(2021 - k) with an AA.

Therefore the sum of the costs of all kk-pals formed using operation (A) is (k+1)×f(k+1)(k + 1)\times f(k + 1). Similarly the sum of the costs of all kk-pals formed using operation (B) is (2021k)×f(k+1)(2021 - k)\times f(k + 1). Hence
f(k)=(k+1)f(k+1)+(2020k)f(k+1)=((k+1)+(2020k))f(k+1)=2021f(k+1). f(k) = (k + 1)f(k + 1) + (2020 - k)f(k + 1) = ((k + 1) + (2020 - k))f(k + 1) = 2021f(k + 1).
Now we note that there are two different 1009-pals, with costs equal to 1010 and 1011 respectively. So
f(1009)=1010+1011=2021. f(1009) = 1010 + 1011 = 2021.
Now if we use the formula f(k)=2021f(k+1)f(k) = 2021f(k + 1) iteratively, we get f(1010i)=2021if(1010 - i) = 2021^{i} for each i=1,2,3,i = 1,2,3,\ldots. Therefore
f(0)=20211010 f(0) = 2021^{1010}
which is our final answer.

Solution 2

Solution:
Let nn be a positive integer. We will find an expression (in terms of nn) for the sum of the costs of all antipalindromes of length 2n2n. Note that a string of AAs and BBs of length 2n2n is an antipalindrome if and only if for each ii, exactly one of the ithi^{\mathrm{th}} and (2n+1i)th(2n + 1 - i)^{\mathrm{th}} letters is an AA (and the other is a BB).

Let x1,x2,,x2nx_{1},x_{2},\ldots ,x_{2n} be variables. For any 1a(1)<a(2)<<a(k)2n1\leq a(1)< a(2)< \dots < a(k)\leq 2n, consider the string of AAs and BBs of length 2n2n, such that the a(j)tha(j)^{\mathrm{th}} letter is AA for all jj (and all the other letters are BB). Let this string correspond to the term t=xa(1)xa(2)xa(3)xa(k)t = x_{a(1)}x_{a(2)}x_{a(3)}\dots x_{a(k)}. If xi=ix_{i} = i for all ii then the value of tt is equal to the cost of its corresponding string. Now consider the expression
y=(x1+x2n)(x2+x2n1)(xn+xn+1)=j=1n(xj+x2n+1j). y = (x_{1} + x_{2n})(x_{2} + x_{2n - 1})\cdot \cdot \cdot (x_{n} + x_{n + 1}) = \prod_{j = 1}^{n}(x_{j} + x_{2n + 1 - j}).
If we expand the brackets then we get 2n2^{n} terms, each in the form t=xa(1)xa(2)xa(3)xa(n)t = x_{a(1)}x_{a(2)}x_{a(3)}\dots x_{a(n)} such that for each j=1,2,,nj = 1,2,\ldots ,n either a(j)=ja(j) = j or a(j)=2n+1ja(j) = 2n + 1 - j. Therefore yy is the sum of all terms that correspond to antipalindromes. Hence if we substitute xi=ix_{i} = i for all ii, then the value of yy would be the sum of the costs of all antipalindromes. So the final answer is:
j=1n(j+(2n+1j))=j=1n(2n+1)=(2n+1)n. \prod_{j = 1}^{n}(j + (2n + 1 - j)) = \prod_{j = 1}^{n}(2n + 1) = (2n + 1)^{n}.

Solution 3

Solution:
Let nn be a positive integer. We will find an expression (in terms of nn) for the sum of the costs of all antipalindromes of length 2n2n. Let P\mathcal{P} denote the set of all antipalindromes of length 2n2n, and let PP be an antipalindrome chosen uniformly from P\mathcal{P}. Note that for each j=1,2,,nj = 1,2,\ldots ,n the jthj^{\mathrm{th}} and (2n+1j)th(2n + 1 - j)^{\mathrm{th}} must be an AA and a BB in some order. Let XjX_{j} be the random variable defined by:
 Xj=j\cdot\ X_{j} = j if the jthj^{\mathrm{th}} letter of PP is an AA and the (2n+1j)th(2n + 1 - j)^{\mathrm{th}} letter is a BB
 Xj=2n+1j\cdot\ X_{j} = 2n + 1 - j if the jthj^{\mathrm{th}} letter of PP is a BB and the (2n+1j)th(2n + 1 - j)^{\mathrm{th}} letter is an AA

Notice that the cost of PP is given by the product X1X2X3XnX_{1}X_{2}X_{3}\cdot \cdot \cdot X_{n}. Now consider fj:PPf_{j}:\mathcal{P}\to \mathcal{P} to be the function which swaps the jthj^{\mathrm{th}} and (2n+1j)(2n + 1 - j) letters of the string. Notice that fjf_{j} is a bijection that toggles the value of XjX_{j}. This means that XjX_{j} is equal to jj or (2n+1j)(2n + 1 - j) with equal probabilities. Therefore
P(Xj=j)=P(Xj=2n+1j)=12. \mathbb{P}(X_{j} = j) = \mathbb{P}(X_{j} = 2n + 1 - j) = \frac{1}{2}.
Furthermore fjf_{j} preserves the value of XiX_{i} for all iji\neq j. Therefore the variables XiX_{i} and XjX_{j} are independent. Therefore the expected value of the cost of PP is given by:
E[cost(P)]=E[i=1nXi]=i=1nE[Xi]=i=1n(12(i)+12(2n+1i))=i=1n2n+12=(2n+12)n. \mathbb{E}[\mathrm{cost}(P)] = \mathbb{E}\left[\prod_{i = 1}^{n}X_{i}\right] \qquad = \prod_{i = 1}^{n}\mathbb{E}\left[X_{i}\right] \qquad = \prod_{i = 1}^{n}\left(\frac{1}{2} (i) + \frac{1}{2} (2n + 1 - i)\right) \qquad = \prod_{i = 1}^{n}\frac{2n + 1}{2} \qquad = \left(\frac{2n + 1}{2}\right)^{n}.
Now the number of antipalindromes of length 2n2n is simply 2n2^{n} (one for each choice of the variables XjX_{j}). Therefore the sum of the costs of all antipalindromes of length 2n2n is simply 2n2^{n} multiplied by the expected value of the cost of PP. This is
2n×(2n+12)n=(2n+1)n. 2^{n}\times \left(\frac{2n + 1}{2}\right)^{n} = (2n + 1)^{n}.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.