V for Vendetta

4.8

4 votes
Medium-Hard
Problem

N unique points are plotted on a 2D plane of form (xi , yi). Total number of distinct interesting pattern ‘V’ needs to be identified that can be made from these points.

Pattern ‘V’: Two distinct congruent line segments sharing a single endpoint each endpoint being a plotted point on the plane.

Distinct patterns don’t consist of same unordered pair of line segments.

Input Format:

First integer T denotes number of test cases.

For each case there is a first line containing integer N.

The next N line contains on i'th line, space separated integers xi & yi

Output Format:

For each case, output total number of distinct patterns that can be made.

Constraints:

1 ≤ T ≤ 5

1 ≤ N ≤ 500

-5000 ≤ xi, yi ≤ 5000

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

For last case, Patterns are :

{ (-5,0), (0,0), (-3,4) }

{ (-5,0), (0,0), (0,5) }

{ (-3,4), (0,0), (0,5) }

enter image description here

Update: For first case, patterns are- { (0,0), (0,1), (0,2) } & { (0,1), (0,2), (0,3) } Let A=(0,0), B=(0,1), C=(0,2), D=(0,3) then line segments AB & BC have same length 1 (congruent line segments), share a single end-point B & all points are plotted on the plane. Thus, it satisfies the given definition of 'V' pattern. Same for pattern with BC & CD.

Editor Image

?