QOJ.ac

QOJ

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

#1701. 锻炼路线

統計

奶牛 Bessie 意识到她需要更多的锻炼来保持良好的体型。她需要你的帮助来选择农场周围的潜在路线,以便进行晨跑。

农场由 $N$ 个田地组成($1 \leq N \leq 2 \cdot 10^5$),编号为 $1 \ldots N$,并由 $M$ 条双向小径连接($1 \leq M \leq 2 \cdot 10^5$)。出于习惯,奶牛们倾向于使用 $N-1$ 条特定的“标准”小径进行日常往来——它们称这些为“标准”小径。仅使用标准小径即可在任意两个田地之间通行。

为了让晨跑更有趣,Bessie 决定选择一条包含一些非标准小径的路线。然而,由于她非常习惯使用标准小径,她不想在路线中使用过多的非标准小径。经过考虑,她认为一条好的路线应该是一个简单环(回到起点,且不重复经过任何田地),并且该环恰好包含两条非标准小径。

请帮助 Bessie 计算她可以选择的好的路线数量。如果两条路线包含的小径集合相同,则视为同一条路线。

输入格式

第一行包含 $N$ 和 $M$。接下来的 $M$ 行中,每行包含两个整数 $a_i$ 和 $b_i$,描述一条小径的两个端点。其中前 $N-1$ 条为标准小径。

输出格式

输出 Bessie 可以选择的好的路线总数。

样例

样例输入 1

5 8
1 2
1 3
1 4
1 5
2 3
3 4
4 5
5 2

样例输出 1

4

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.