luogu#P17320. [ICPC 2018 Nanjing R] Cherry and Chocolate

[ICPC 2018 Nanjing R] Cherry and Chocolate

Problem Description

Cherry and Chocolate play a game on a tree. First, Cherry picks a node and paints it pink. Then, Chocolate picks another node and paints it brown. Afterwards, Cherry picks yet another node and paints it pink. The game ends here. Chocolate doesn't get the second move.

For each node vv, if there is no path from vv to the brown node without passing through a pink node, Cherry gets a point.

Cherry wants to maximize her score, and Chocolate wants to minimize it. If both players play optimally, what will Cherry's score be?

Input Format

The first line contains an integer, nn (3≤n≤1053 \le n \le 10^5), the number of nodes on the tree.

Each of the next n−1n - 1 lines contains two integers aia_i and bib_i,(1≤ai,bi≤n1 \le a_i, b_i \le n), meaning there is an edge between node aia_i and node bib_i.

Output Format

A single integer, Cherry's score if both players play optimally.

4
1 2
2 3
2 4
3