#P3021. Symmetric Bridge Groups
Symmetric Bridge Groups
Symmetric Bridge Groups
Farmer John's cows are waiting in the pasture at integer coordinate positions. They want to form groups of four to play Bridge. Four cows can form a valid Bridge group if and only if there exists a point (X) in the plane (which is not coincident with any of the four cow positions) such that rotating any cow 180° about (X) (i.e. reflecting it through (X)) lands at the position of another cow in the group. In other words, the four cows can be partitioned into two pairs that are symmetric with respect to the same point (X).
Given (N) ((4 \leq N \leq 1000)) cows with coordinates ( (X_i, Y_i) ) (where (-10^9 \leq X_i, Y_i \leq 10^9)), count the number of distinct sets of four cows that can form a Bridge group.
Note: The point (X) is defined as the midpoint of each pair. Since rotating a point by 180° about (X) gives its reflection, the condition requires that there exist two disjoint pairs of cows having the same midpoint (X). Also, by definition, (X) cannot coincide with any of the four cow positions.
inputFormat
The first line contains an integer (N), the number of cows. Each of the next (N) lines contains two space-separated integers (X_i) and (Y_i), representing the coordinates of the (i)-th cow.
outputFormat
Output a single integer: the number of sets of four cows that can form a valid Bridge group.
sample
8
-3 1
-2 2
-3 0
-2 0
-1 1
0 3
2 0
3 0
3