← All problemsSign in

Tree Interval Queries

CodeChefRating 3575Open on judge ↗

You are given a tree with $N$ vertices numbered $1, 2, \ldots, N$. First, you sort the adjacency lists of all the vertices and run depth first search from node $1$. This gives you an array of dfs start times. Note that the start times are uniquely determined, as the adjacency list of each vertex is sorted. The following code represents the dfs: ```cpp // let st denote the start times // l

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