← All problemsSign in

Yet Another Tree Problem

CodeChefRating 2382Open on judge ↗

You are given a connected graph with $N$ vertices (numbered $1$ through $N$) and $N - 1$ bidirectional edges. Also, you are given a sequence $K_1, K_2, \ldots, K_N$. Let's denote the distance between vertices $u$ and $v$ by $d(u, v)$. Next, for each valid $i$, let's define $D_i$ as the maximum integer such that there are at least $K_i$ vertices $v$ with $d(i, v) \gt D_i$. (It can be proven that

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