当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6881:Tree Cutting

题目描述
Given a tree (connected undirected graph with $n$ vertexes and $n - 1$ edges), you are required to delete as few vertexes as possible such that the remaining graph is still a tree and its diameter shall not exceed $k$. The diameter of a tree is the length of its longest path.
输入解释
The first line contains one positive integer $T$ ($1\le T \le 15$), denoting the number of test cases. For each test case:

The first line of the input contains two integers $n, k\,(1\le n,k \le 300000)$.

Each of the following $n - 1$ lines contains two integers $u, v\, (1\le u,v \le n, u\neq v)$, indicating that there is an edge connecting vertex $u$ and $v$ in the tree.
输出解释
For each test case:

You should just output one integer indicating the number of vertexes to be deleted.
输入样例
1
10 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
输出样例
4
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6881

最后修改于 2020-10-25T23:35:13+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 262144/262144K(Java/Others)