Hourglass 2
Time limit1.5sMemory limit1024 MB
Given N points with no three collinear, count the pairs of non-overlapping triangles that share exactly one vertex.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Two pointers
- Solved
- No attempts yet
Problem
Following the hourglass craftsman Taehee, Kukryeol takes the points given on the coordinate plane and extracts hourglasses from them.
An hourglass looks like this.

[figure] Hourglass
More precisely, a figure that satisfies the following conditions is called an hourglass.
- It is made of two triangles that share one point.
- The two triangles must not overlap each other.
For two hourglasses, if the union of their vertices and edges is the same as one of the two hourglasses, they are called the same hourglass. Any two hourglasses that do not satisfy this condition are different hourglasses.
Like Taehee, Kukryeol wants to count hourglasses quickly. Help Kukryeol challenge Taehee.
Input
N
x1 y1
. . .
xN yN
Output
Print the number of hourglasses that can be made.
Constraints
- 1 ≤ N ≤ 1,500. This is the number of points on the plane.
- . The coordinates of the i-th point. (1 ≤ i ≤ N)
- No three points lie on a single line.
- All numbers in the input are integers.