QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#8973. 樱桃与巧克力

统计

Cherry 和 Chocolate 在一棵树上玩游戏。首先,Cherry 选择一个节点并将其涂成粉色。然后,Chocolate 选择另一个节点并将其涂成棕色。之后,Cherry 再选择一个节点并将其涂成粉色。游戏到此结束。Chocolate 没有第二次行动的机会。

对于每个节点 $v$,如果从 $v$ 到棕色节点的路径上必然经过至少一个粉色节点,则 Cherry 获得一分。

Cherry 希望最大化她的得分,而 Chocolate 希望最小化该得分。如果双方都采取最优策略,Cherry 的得分会是多少?

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 10^5$),表示树的节点数。

接下来的 $n - 1$ 行,每行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n$),表示节点 $a_i$ 和 $b_i$ 之间有一条边。

输出格式

输出一个整数,表示双方采取最优策略时 Cherry 的得分。

样例

样例输入 1

4
1 2
2 3
2 4

样例输出 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.