Good Triangle
Time limit2sMemory limit1024 MB
Count the triples of distinct points for which some point T is equidistant from all three under Manhattan distance, with up to 500000 points.
- Level
Medium7 of 10
- Topics
- Geometry, Combinatorics, Prefix sum
- Solved
- No attempts yet
Problem
You are given distinct points on the two dimensional plane.
The distance between two points and is .
Three distinct points form a good triangle if there exists a point such that . does not have to be a lattice point.
Find the number of good triangles that can be formed from the given points.
Input
The first line contains . Each of the next lines contains two space-separated integers , the coordinates of the -th point.
Output
Print one integer, the number of good triangles.
Constraints
- ()
- if ()
- All values in the input are integers.