2213. Monochromatic triangles

单点时限: 2.0 sec

内存限制: 256 MB

There are n points given in a space. There are no three points, such that they lie on the same straight line. Each pair of points is connected by a segment coloured red or black. Each triangle, whose sides have the same colour is called a monochromatic triangle. We are given a list of all red segments and we want to find the number of all monochromatic triangles.

Write a program that:

  • reads the following data: the number of points, the number of red segments and their list,

  • finds the number of monochromatic triangles,

  • writes the result.

输入格式

In the first line there is one integer n, 3 <= n <= 1000, which equals the number of points.

In the second line there is one integer m, 0 <= m <= 250000, which equals the number of red segments.

In each of the following m lines there are two integers p and k separated by a single space, 1 <= p < k <= n. They are numbers of vertices which are ends of a red segment.

输出格式

In the first line there should be written one integer - the number of monochromatic triangles.

样例

Input
6
9
1 2
2 3
2 5
1 4
1 6
3 4
4 5
5 6
3 6
Output
2

11 人解决,14 人已尝试。

12 份提交通过,共有 36 份提交。

5.6 EMB 奖励。

创建: 15 年,9 月前.

修改: 6 年,8 月前.

最后提交: 3 年,5 月前.

来源: POI 1997 III Stage

题目标签