Problem

Source: 2020 New Zealand MO Round 2 p5 NZMO

Tags: combinatorics



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