Polish version    English version  
  History of OI -> IV OI 1996/1997 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Organization
Hints
Schedule
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
IV Olimpiada Informatyczna 1996/1997

Task: TRO
Author: Wojciech Guzicki
Monochromatic triangles

III stage contest  
Source fileTRO.??? (e.g. PAS,C, CPP)
Executable fileTRO.EXE
Input fileTRO.IN
Output fileTRO.OUT

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.

Task

Write a program that:
  • reads from the text file TRO.IN the following data: the number of points, the number of red segments and their list,
  • finds the number of monochromatic triangles,
  • writes the result to the text file TRO.OUT.

Input

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

In the second line of the same file 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.

Output

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

Example

For the text file TRO.IN:
6 
9
1 2
2 3
2 5
1 4
1 6
3 4
4 5
5 6
3 6
the correct solution is the text file TRO.OUT
2





Print friendly version