Nastia Plays with a Tree Solution Codeforces 2021
SOLUTION
” CLICK HERE “
Nastia has an unweighted tree with
The girl will perform the following operation with her tree, as long as she needs:
- Remove any existing edge.
- Add an edge between any pair of vertices.
What is the minimum number of operations Nastia needs to get a bamboo from a tree? A bamboo is a tree in which no node has a degree greater than
The first line contains a single integer
The first line of each test case contains a single integer
Next
It's guaranteed the given graph is a tree and the sum of
For each test case in the first line print a single integer
In the next
Note that the edge
2 7 1 2 1 3 2 4 2 5 3 6 3 7 4 1 2 1 3 3 4
2 2 5 6 7 3 6 4 5 0
Note the graph can be unconnected after a certain operation.
Consider the first test case of the example:


Social Plugin