题目地址
题目
Given an unrooted tree, you should choose the minimum number of chains that all edges in the tree are covered by at least one chain. Print the minimum number and one solution. If there are multiple solutions, print any of them.
输入描述
The first line contains one integer(1≤n≤2×10 5),denoting the size of the tree.Following n−1 lines each contains two integers u,v (1≤u<v≤n), denoting an edge in the tree.It’s guaranteed that the given graph forms a tree.
输出描述
The first line contains one integer k, denoting the minimum number of chains to cover all edges.
Following k lines each contains two integers u,v (1≤u,v≤n), denoting a chain you have chosen. Here u=v is permitted, which covers no edge.
样例输入
5
1 2
1 3
2 4
2 5