Problem

Source: Belarusian National Olympiad 2021

Tags: combinatorics



Several soldiers are standing in a row. After a command each of them turned their head either to the left or to the right. After that every second every soldier performs the following operation simultaneously: 1) if the soldier is facing right and the majority of soldiers to the right of him are facing left, he starts facing left; 2) if the soldier is facing left and the majority of soldiers to the left of him are facing right, he starts facing right; 3) otherwise he does nothing. Prove that at some point the process will stop.