Ancient Towers
Time limit7sMemory limit1024 MB
Count the simple quadrilaterals formed by four of N given points whose area is at least S.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Two pointers, Combinatorics
- Solved
- No attempts yet
Problem
The king of Nlogonia has conquered many lands throughout his life, and now that his son has come of age, the king wants to share his possessions with him.
Nlogonia has ancient towers that can be seen as points in the Cartesian plane. The king decided that his son must choose four of those towers. Then the son must build a wall connecting the towers, so as to form a (simple but not necessarily convex) quadrilateral with the towers as vertices. The land surrounded by the wall will be owned by the son. The king does not want people making fun of his son for not having enough land, so the area of the quadrilateral must be greater than or equal to a given value .
The son is eager to choose his portion of the land, but the king wants to know beforehand in how many different ways this can be done. The picture below shows an example with towers. In this case, there are two different quadrilaterals with an area of at least .

A quadrilateral is simple if non-contiguous edges do not intersect.
Input
The first line contains two integers () and (). Each of the next lines contains two integers and (), the coordinates of a tower. No two towers have the same location, and no three of them are collinear.
Output
Output a single integer, the number of different simple quadrilaterals that have towers as vertices and an area of at least . Two quadrilaterals are considered different if they have different vertices or different edges.