#P6355. [COCI 2007/2008 #3] DEJAVU
[COCI 2007/2008 #3] DEJAVU
Problem Description
Given points on a plane, compute how many different right triangles there are such that all their vertices are among the given points, and both legs are parallel to the coordinate axes.
Two right triangles are different if and only if they have at least one different vertex.
Input Format
The first line contains an integer , the number of points.
The next lines each contain two integers, giving the coordinates of a point.
Output Format
Output the number of right triangles.
3
4 2
2 1
1 3
0
5
1 2
2 1
2 2
2 3
3 2
4
6
10 10
20 10
10 20
20 20
30 20
30 30
8
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , the coordinate values are between and , and no two points have the same coordinates.
Notes
This problem is translated from COCI2007-2008 CONTEST #3 T4 DEJAVU.
Translated by ChatGPT 5