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

    ID: 16800 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>贪心博弈论2018线段树点分治树链剖分ICPC分类讨论南京树的重心

[ICPC 2018 Nanjing R] Cherry and Chocolate

题目描述

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?

输入格式

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.

输出格式

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

4
1 2
2 3
2 4
3