Explorer Bo

TimeLimit:5000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Explorer Bo likes exploring mazes around the world.Now he wants to explore a new maze.

The maze has $N$ rooms connected with $N-1$ roads of length $1$ so that the maze looks like a tree.

Explorer Bo can transfer to a room immediately or walk along a road which is not the one he walked just now.

Because the transfer costs too much, Mr Bo will minimum the transfer using times firstly.

Mr Bo wants to walk along all the roads at least once,but he is lazy and he wants to minimum the total length he walked.

Please help him!

Initial point can be arbitrarily selected
Input
The first line of input contains only one integer $T(=20)$, the number of test cases.

For each case, the first line contains $1$ integers, $N( \leq 100000)$ as described before. The following $N-1$ lines describe the path. Each line has $2$ integers, $X,Y(1<=X, Y<=N)$,that there is a road between $X$ and $Y$.
Output
Each output should occupy one line.For each case, just output the minimum length to explore all roads.
SampleInput
2
3
1 2
2 3
7
1 2
1 3
2 4
2 5
3 6
3 7
SampleOutput
2
8
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数4
总提交量4
AC率75.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

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