#P6057. [加油武汉] 七步洗手法

[加油武汉] 七步洗手法

Background

We are currently at a critical stage of epidemic prevention and control. Everyone should wash their hands often to prevent infection through contact.

Correct handwashing method

Problem Description

Given an undirected complete graph with nn vertices, where mm edges are white and the remaining edges are black.

You need to find the number of monochromatic 3-cycles (that is, triangles).

Input Format

The first line contains integers n,mn, m, with the meaning as described above.

The remaining mm lines each contain two integers u,vu, v, representing the two endpoints of a white edge. It is guaranteed that the given white edges have no multiple edges and no self-loops.

Output Format

Output one integer in one line, which is the answer.

5 3
1 5
2 5
3 5
4

Hint

  • For 20%20\% of the testdata, n200n \leq 200.
  • For 50%50\% of the testdata, n2000n \leq 2000.
  • For 100%100\% of the testdata, 1n1051 \leq n \leq 10^5, 1m3×1051 \leq m \leq 3\times 10^5.

Translated by ChatGPT 5