QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#2061. 巡视

統計

Polycarp 访问了 Berland 的城市 Bytegorsk,以检查该市所有的公交线路。

Bytegorsk 的道路网络由 $N$ 个公交车站和若干条双向道路组成,这些道路的连接方式使得任意两个公交车站之间都只有唯一的一条路径(无论是直接连接还是通过其他车站)。公交车通过任意两个相邻车站(即由道路直接相连的车站)之间距离所需的时间为 1 分钟。

对于 Bytegorsk 中的任意两个公交车站,都存在一条连接这两个车站的公交快线,该快线忽略沿途的其他车站。Polycarp 想要至少检查每一条这样的快线一次(方向不限)。

计算 Polycarp 检查所有公交快线所需的最少时间。

输入格式

第一行包含一个整数 $N$ —— 公交车站的数量 ($1 \le N \le 2 \times 10^5$)。

接下来的 $N-1$ 行,每行包含一条道路的描述 —— 两个整数 $a$ 和 $b$ ($1 \le a, b \le N; a \neq b$),表示该道路连接的车站编号。保证每对车站最多被列出一次。

输出格式

输出一个整数 —— Polycarp 检查所有公交快线所需的最少时间。

样例

样例输入 1

5
1 2
1 3
3 4
3 5

样例输出 1

18

样例输入 2

2
2 1

样例输出 2

1

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.