Ensure that you are logged in and have the required permissions to access the test.

Orthogonal Pairs

4.5

8 votes
Mathematics, Easy-Medium, Mathematics, Mathamatics
Problem

You are given a 2D plane containing N distinct integral points in the form of (X,Y). Now a line segment is drawn between each pair of points. Your task is to determine the number of unordered pairs of these line segments that are orthogonal to each other. 

Input format

  • First line: N
  • Next N lines: Two space-separated integers X and Y denoting a point on the plane

Output format

Print a single integer that represents the number of quadruples as described in the problem statement

Constraints

1N2103

2103X,Y2103

Subtasks

  • For 20 points: 1N100
  • For 80 points: Implement the original constraints
Sample Input
5
1 1
2 2
0 0
1 -1
-1 1
Sample Output
10
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Let the points be labelled P1,P2,P3,P4,P5 respectively according to the order in the sample input. One of the possible quadruple is P2,P3,P4,P5 because the angle between the line segments P2,P3 and P4,P5 is 90o. There are 9 more such quadruples. Hence the answer to this sample case is 10.

Editor Image

?