Official algorithmic problem description and constraints.
Two players, Alice and Bob, are playing a game. They have π piles of stones, with the π-th pile initially containing ππ stones.
On their turn, a player can choose any pile of stones and take any positive number of stones from it, with one condition:
The player who cannot make a move loses. Both players play optimally (that is, if a player has a strategy that allows them to win, no matter how the opponent responds, they will win). Alice goes first.
Determine who will win.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.