Tree Cutting

TimeLimit:10000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
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.
Input
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.
Output
For each test case:

You should just output one integer indicating the number of vertexes to be deleted.
SampleInput
1
10 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
SampleOutput
4
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量1
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: