← All problemsSign in

B - Shailesh Got Bored (easy)

Shailesh got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j ($1 \leq  i \leq  j \leq  n$) and changes all values ak to ak ⊕ 1 for which their positions are in range [i, j] (that is $i \leq  k \leq  j$). (where ⊕ indicates xor) The goal of the

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