Arrow Collector
Time limit4sMemory limit512 MB
Count the ordered tuples (A, B, C, D) of points that form an upper-left arrow, where C and D lie in the 90-degree cone at A and are closer to A than B.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Two pointers
- Solved
- No attempts yet
Problem
Dong-hyeon is an arrow collector who gathers arrows. Lately he is very excited because he recently found an arrow mine with as many as points. All points are distinct, and no three points lie on one line.
To mine arrows from the mine, one must pick four different points among the points and connect them. There are several ways to connect four points into an arrow, but the most valuable one is ↖️, named arrow_upper_left. ↖️ is defined as an ordered tuple of four distinct points that satisfies the following conditions.
- The coordinate of is less than that of , and the coordinate of is greater than that of .
- Seen from , is located clockwise from by more than 0 and less than 90 degrees.
- Seen from , is located counterclockwise from by more than 0 and less than 90 degrees.
- Both segments and are shorter than segment .
Dong-hyeon wants to mine every kind of ↖️ in this mine, but first he wants to know how many distinct ↖️ exist. Two ↖️ are different if their ordered four-point tuples differ. Count them for him.
Input
The first line contains , the number of points in the arrow mine. The next lines each contain two integers and , separated by a space, giving the coordinates of a point.
Output
Print the number of distinct ↖️ in the arrow mine.
Constraints
- All points are distinct, and no three points lie on one line.