Day 6 - The Simple Problem

0

0 votes
Medium
Problem

There are N points in an X-Y plane. The coordinates of ith point is (Xi,Yi).

We can form triangles using a set of any 3 points.

The question is very simple.

Find the sum of area of all the triangles formed using the points from the above set. Let this sum be called S.

Among these, Find the sum of area of those triangles whose any of the sides are vertical. Let this sum be called s.

We say Result R = S-s

INPUT

The first line of input consists of T denoting number of test cases.

The first line of each test case consists of a single integer N denoting number of points.

Each of the next N lines consists of 2 space separated integers Xi and Yi i.e. the coordinates of the corresponding point.

All the coordinates are distinct.

OUTPUT

For each test case, output a single real number i.e. the value R.

Each of the output should exactly contain 9 digits after decimal.

CONSTRAINTS

1 ≤ T ≤ 30

1 ≤ N ≤ 2500

1 ≤ Xi ≤ 4

1 ≤ Yi ≤ 106

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Possible valid triangles having non zero area:

{(1,1), (2,7), (3,1)} Area=6

{(1,1), (2,7), (4,1)} Area=9

{(3,1), (2,7), (4,1)} Area=3

Total Area=18

Editor Image

?