QOJ.ac

QOJ

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

#3544. 仙人掌图上的距离之和

統計

计算仙人掌图中所有顶点对之间的距离之和。仙人掌图是一种每条边最多属于一个简单环的图。顶点之间的距离定义为连接给定顶点对的最短路径中的边数。

输入格式

第一行包含两个整数 $n$ 和 $m$,分别表示仙人掌图中的顶点数和边数。 接下来的 $m$ 行,每行包含两个整数 $u_i, v_i$,表示由一条边连接的两个顶点的编号。

保证图是连通的,且没有自环和重边。

$$1 \le n \le 10^5$$ $$n - 1 \le m \le 2 \times n$$ $$1 \le u_i, v_i \le n$$

输出格式

输出一行,包含所有顶点对之间的距离之和。

样例

样例输入 1

3 3
1 2
2 3
3 1

样例输出 1

3

样例输入 2

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

样例输出 2

42

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.