QOJ.ac

QOJ

Time Limit: 8 s Memory Limit: 512 MB Total points: 10 Difficulty: [show]

#1395. 三条路 [A]

Statistics

Bajtocja 国王 Bajtur 喜欢梦想征服 Bitocja。梦想击败对手固然美好,但现实生活并非梦境,情况往往有所不同。

Bajtocja 由 $n$ 个城市(编号从 $1$ 到 $n$)组成,这些城市由 $m$ 条双向道路连接。每条道路连接两个不同的城市,但可能存在多条道路连接同一对城市的情况。从任何一个城市出发,都可以通过若干条道路到达其他任何城市。

国王想知道,如果 Bitocja 袭击 Bajtocja 并摧毁了现有的 $m$ 条道路中的任意三条,会对国家的交通造成多大的破坏?你的任务是计算:有多少种三条道路的组合,使得在摧毁它们之后,至少存在一对城市无法通过剩余的道路互相到达。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($2 \le n \le 200\,000$, $3 \le m \le 500\,000$),分别表示 Bajtocja 的城市数量和道路数量。

接下来的 $m$ 行描述了道路;第 $i$ 行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n, a_i \neq b_i$),表示第 $i$ 条道路连接城市 $a_i$ 和 $b_i$。

你可以假设道路网络保证了从任何城市都能到达其他任何城市。

输出格式

输出一个整数,表示满足以下条件的无序道路三元组的数量:移除这三条道路后,至少存在一对城市无法互相到达。

样例

输入 1

8 11
2 3
4 5
3 1
3 2
5 7
3 6
1 2
3 4
6 5
8 7
7 8

输出 1

103

说明 1

请注意,例如在移除第三、第五和第七条道路后,Bajtocja 将分裂成超过两个部分。尽管如此,这样的一组三条边仍应只被计算一次。

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.