← All problemsSign in

Random NIM

CodeChefRating 1475Open on judge ↗

There are $N$ piles numbered $1, 2, \ldots, N$. The $i$-th pile initially has $A_i$ stones. Alice and Bob are playing a Nim game on these piles, but there is a twist. As per the usual rules of Nim, Alice and Bob take turns alternately choosing a pile and removing some stones from the pile, with Alice going first. The player unable to make a move loses. However, the twist is that instead of choos

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