QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 128 MB مجموع النقاط: 100

#13319. 凯旋门

الإحصائيات

Byteotia 的国王 Byteasar 在一场胜利的战役后正返回他的国家。Byteotia 有 $n$ 个城镇,由 $n-1$ 条道路连接。已知从任意一个城镇出发,都可以通过唯一的一条路径到达其他任何城镇(换句话说,道路网络构成了一棵树)。

国王刚刚进入首都。在那里,一座凯旋门(即胜利的国王穿过的门)已经竖立起来。Byteasar 对臣民们的热烈欢迎感到高兴,他计划进行一次凯旋游行,访问 Byteotia 的所有城镇,并从他目前所在的首都出发。

其他城镇还没有准备好迎接国王——这些城镇的凯旋门建设甚至还没有开始!但 Byteasar 的心腹顾问正在处理这个问题。他希望雇佣一些施工队。每个施工队每天可以在任何一个城镇建造一座拱门。不幸的是,没有人知道国王访问城镇的顺序。唯一确定的是,国王每天都会从他当前所在的城市移动到相邻的一个城市。国王可能会多次访问同一个城镇(但由于他并不虚荣,每个城镇只需要一座拱门就足够了)。

Byteasar 的顾问必须向每个施工队支付相同的固定费用,无论该施工队建造了多少座拱门。因此,虽然他需要确保国王访问每个城镇时该城镇都已经有了一座拱门,但他希望雇佣尽可能少的施工队。请编写一个程序,确定能够及时完成拱门建设所需的最少施工队数量,以帮助他解决这个问题。

输入格式

标准输入的第一行包含一个整数 $n$ ($1 \le n \le 300\,000$),表示 Byteotia 的城镇数量。城镇编号从 $1$ 到 $n$,其中 $1$ 号对应首都。

接下来的 $n-1$ 行描述了道路网络。每行包含两个整数 $a, b$ ($1 \le a, b \le n$),由一个空格分隔,表示城镇 $a$ 和 $b$ 之间有一条双向道路直接相连。

输出格式

标准输出的第一行且仅包含一行,输出一个整数,表示 Byteasar 的顾问需要雇佣的最少施工队数量。

样例

输入 1

7
1 2
1 3
2 5
2 6
7 2
4 1

输出 1

3

第一天,需要在城镇 2, 3, 4 竖立凯旋门。第二天,需要在城镇 5, 6, 7 竖立凯旋门。

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.