← All problemsSign in

Alternative Sufferings

CodeChefRating 2011Open on judge ↗

You are given a binary string $S$. In one second, the following scenario happens **simultaneously** and **independently** for **all** the bits which are set to $1$ in the string: - Change the bit from $1$ to $0$. - If the left neighbour exists and is $0$, change it to $1$. - If the right neighbour exists and is $0$, change it to $1$. For example, if $S = 010$ initially, then after $1$ second, $

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