Apple
CodeChefOpen on judge ↗
Bob is never full of gifts. In order to open gifts, he has to solve Alice's puzzle. There are N boxes numbered from 1 to N. Each box is either empty or contains a gift. Distance d between any pair of boxes is defined as the difference of their indices. For every value of d from 0 to N - 1, Bob has to tell the count of distinct pair of boxes such that the distance between them is d and both boxes
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