#abc262b. B - Triangle (Easier)

B - Triangle (Easier)

Score : 200200 points

问题描述

你被给定一个包含 NN 个顶点和 MM 条边的简单无向图。顶点编号为 1,,N1, \dots, N,第 ii-条 (1iM)(1 \leq i \leq M) 边连接顶点 UiU_i 和顶点 ViV_i

求满足以下所有条件的整数元组 (a,b,c)(a, b, c) 的数量:

  • 1a<b<cN1 \leq a < b < c \leq N
  • 存在一条连接顶点 aa 和顶点 bb 的边。
  • 存在一条连接顶点 bb 和顶点 cc 的边。
  • 存在一条连接顶点 cc 和顶点 aa 的边。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a simple undirected graph with NN vertices and MM edges. The vertices are numbered 1,,N1, \dots, N, and the ii-th (1iM)(1 \leq i \leq M) edge connects Vertex UiU_i and Vertex ViV_i.

Find the number of tuples of integers a,b,ca, b, c that satisfy all of the following conditions:

  • 1a<b<cN1 \leq a \lt b \lt c \leq N
  • There is an edge connecting Vertex aa and Vertex bb.
  • There is an edge connecting Vertex bb and Vertex cc.
  • There is an edge connecting Vertex cc and Vertex aa.

Constraints

  • 3N1003 \leq N \leq 100
  • 1MN(N1)21 \leq M \leq \frac{N(N - 1)}{2}
  • 1Ui<ViN(1iM)1 \leq U_i \lt V_i \leq N \, (1 \leq i \leq M)
  • (Ui,Vi)(Uj,Vj)(ij)(U_i, V_i) \neq (U_j, V_j) \, (i \neq j)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

U1U_1 V1V_1

\vdots

UMU_M VMV_M

Output

Print the answer.

Sample Input 1

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

Sample Output 1

2

(a,b,c)=(1,4,5),(2,3,5)(a, b, c) = (1, 4, 5), (2, 3, 5) satisfy the conditions.

Sample Input 2

3 1
1 2

Sample Output 2

0

Sample Input 3

7 10
1 7
5 7
2 5
3 6
4 7
1 5
2 4
1 3
1 6
2 7

Sample Output 3

4

update @ 2024/3/10 11:05:47