← All problemsSign in

Game of Piles Version 1

CodeChefRating 1135Open on judge ↗

There are $N$ piles where the $i^{th}$ pile consists of $A_i$ stones. Chef and Chefina are playing a game taking alternate turns with **Chef starting first**. In his/her turn, a player can choose any non-empty pile and remove **exactly** $1$ stone from it. The game ends when **exactly** $1$ pile becomes empty. The player who made the last move wins. Determine the winner if both players play

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start