← All problemsSign in

Musical Chairs

CodeChefRating 2831Open on judge ↗

$N$ people play a game of musical chairs — with a bit of a twist. There are $N$ chairs arranged in a circle in clockwise order, numbered $1, 2, 3, \ldots, N$. For each $1 \leq i \lt N$, chair $i$ is followed by chair $(i+1)$, and chair $N$ is followed by chair $1$. Initially, person $i$ stands in front of chair $i$. Further, chair $i$ has color $C_i$, and person $i$ is given a *banned* colo

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