← All problemsSign in

Arithmetic Jumping

CodeChefRating 3242Open on judge ↗

You are given a [tree](https://en.wikipedia.org/wiki/Tree_(data_structure)) with $N$ vertices. We call a sequence of vertices $[A_1, A_2, \ldots, A_K]$ *cool* if $dis(A_i, A_{(i+1)}) = i$ for $1 \leq i \lt K$. Here, $dis(u, v)$ denotes the length of the shortest path between vertices $u$ and $v$. Note that, the sequence $A$ may contain **duplicate** vertices as well. You need to answer $M$ qu

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