Solution to the EquiLeader problem in C++