TRIANGLE problem.Need urgent solution?

Given N points in 2D plane, calculate the number of right triangles that can be formed using these N points such that their shorter sides are parallel to the coordinate axis. Two points should be considered different even if they have same x and y co-ordinates.
Input/Output
You don’t have to read or write anything from/to stdin and stdout respectively. Use the template code provided in the editor on the submission page, that does the IO for you.

In the template, you have to write a function that takes 3 arguments, N and two 1 dimensional array, containing the X and Y coordinates of the ith point respectively and returns the number of right triangles that can be formed.

Function Signature:
long long rt_triangle(int N, int A[50000], int B[50000]);

The template code executes the function submitted T times with different arguments.
Constraints

0 < T <= 50
0 < N <= 15000
-50000 <= X cord, Y cord <= 50000

Example

rt_triangle(4, {1, -5, -2, -2}, {3, -2, 4, 1}) should return 0.
rt_triangle(4, {0, -1, -1, 1}, {1, -2, 1, -2}) should return 0.
Sample Input File

2
4
1 3
-5 -2
-2 -4
-2 1
4
0 1
-1 -2
-1 1
1 -2

Output

0
2

Is this from an ongoing contest?

3 Likes

@hruday968 It is a problem from Practice (Peer) : LINK

@abcool I am also interested for an answer for this kind of problem with 0 submission. And I believe, it would be cool if you’re the first one to submit.