MathDB
Operation with binary strings

Source: All-Russian MO 2023 Final stage 9.2

April 23, 2023
combinatorics

Problem Statement

Initially, a word of 250250 letters with 125125 letters AA and 125125 letters BB is written on a blackboard. In each operation, we may choose a contiguous string of any length with equal number of letters AA and equal number of letters BB, reverse those letters and then swap each BB with AA and each AA with BB (Example: ABABBAABABBA after the operation becomes BAABABBAABAB). Decide if it possible to choose initial word, so that after some operations, it will become the same as the first word, but in reverse order.