UHCC1 P5 - Binary Triangles

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 2.5s
Java 4.0s
PyPy 2 4.0s
PyPy 3 4.0s
Memory limit: 256M

Author:
Problem types

Rain loves triangles, especially equilateral ones. Thus, Rain has N points in M-dimensional space where each coordinate point is either 0 or 1, and he wants you to calculate the number of equilateral triangles with vertices on the points. The distance between two points is the usual Euclidean distance.

The Euclidean distance between points a=(a1,a2,,aM),b=(b1,b2,,bM) is (a1b1)2+(a2b2)2++(aMbM)2.

Constraints

The points are pairwise-distinct.

1N400

1M5×104

aij{0,1}

Subtask 1 [80%]

1N,M400

Subtask 2 [20%]

No additional constraints.

Input Specification

The first line contains two integers N and M.

The next N lines each represent a point ai. Each line has M integers ai1,,aiM, representing the coordinates of the point.

Output Specification

Output the number of equilateral triangles where each vertex is a given point.

Sample Input

Copy
4 3
0 0 1
1 0 0
0 1 0
0 1 1

Sample Output

Copy
1

Explanation for Sample

Only the first 3 points form an equilateral triangle.


Comments

There are no comments at the moment.