← All problemsSign in

Random Nim

CodeChefRating 1523Open on judge ↗

Alice and Bob are playing a modified version of the Nim game. There are $N$ piles of stones, where the $i^{th}$ pile contains $A_i$ stones. In each turn, Alice and Bob roll a fair $D$-sided die. The player who rolls the higher number gets to make a move. If they roll the same number, Alice gets to make the move. During their turn, a player must select **exactly one** non-empty pile and remove **

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