Official algorithmic problem description and constraints.
Alice and Bob are playing a game on π piles of stones. On each player's turn, they select a positive integer π that is at most the size of the smallest nonempty pile and remove π stones from each nonempty pile at once. The first player who is unable to make a move (because all piles are empty) loses.
Given that Alice goes first, who will win the game if both players play optimally?
Detailed video explanations, mathematical intuition, and clean C++ implementation code.