QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 1024 MB Points totaux : 100

#2404. 剑计数

Statistiques

Michael 计划开设一家图商店。图商店是一种专门销售各种不同大小和形状的图的商店。Michael 对市场进行了广泛的研究,这项业务看起来非常有利可图。他还发明了一种图生成装置,能够生成他想要的任何图。

然而,有一个小问题阻碍了他开启这项蓬勃发展的业务:Michael 不知道每张图应该如何定价。经过几周的阅读,他发现一张图的价值可以根据其“剑形子树”(sword subtrees)的数量来计算。如果一组六个不同的顶点(我们用字母 A 到 F 表示)满足以下边关系,则它们构成一个剑形子树(见图):

  • A 与 B 相连。
  • B 与 A 和 D 相连。
  • C 与 D 相连。
  • D 与 B、C、E 和 F 相连。
  • E 与 D 相连。
  • F 与 D 相连。

如果两个剑形子树 $T_1$ 和 $T_2$ 之间存在一条边 $e$ 属于 $T_1$ 但不属于 $T_2$,则认为它们是不同的。

作为一名知识渊博的人和他的商业伙伴,你的任务是帮助 Michael 计算他生成的图中剑形子树的数量。给定一个无向图,编写一个程序来计算其剑形子树的数量。

输入格式

输入的第一行包含两个整数 $N$ 和 $M$ ($1 \le N, M \le 100\,000$),分别表示图中的顶点数和边数。接下来的 $M$ 行,每行包含两个整数 $u_i$ 和 $v_i$ ($1 \le u_i, v_i \le N$),表示一条无向边的两个端点。保证所描述的图中不包含重边或自环。

输出格式

输出一个整数,即给定图中剑形子树的数量。

样例

样例输入 1

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

样例输出 1

6

样例输入 2

6 15
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

样例输出 2

120

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.