Magic Array
CodeChefOpen on judge ↗
Sonya loves problems with sequences, so she has a large collection of different sequences at home. Some of these sequences are magic sequences. A *magic sequence* with length $N$ is an integer sequence $s_1, s_2, \ldots, s_N$ with the following properties: - At least one of its elements is $0$. - For each valid $i$, $s_i$ is the distance of element $s_i$ to the closest zero element. Formally,
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.
Sign in to chat with the tutor and save your progress.
Sign in to start