P9678 [ICPC 2022 Jinan R] Tree Distance

题目描述

You are given an unrooted weighted tree $T$ with vertices $1, 2, \ldots, n$. Please answer some queries. We define $\texttt{dist}(i,j)$ as the distance between vertex $i$ and vertex $j$ in $T$. For each query, you are given two integers $l, r$. Please answer the value of $$\min_{l\le i< j\le r}(\texttt{dist}(i,j)).$$

输入格式

输出格式