Three Points
Time limit2sMemory limit512 MB
Count triples of points where the x coordinates increase and the y coordinates order as r < b < g.
- Level
Medium7 of 10
- Topics
- Sorting, Prefix sum, Combinatorics
- Solved
- No attempts yet
Problem
There are N points on an infinite two-dimensional plane. The points are numbered 0 through N-1, and point i lies at . No two points share an x coordinate, and no two points share a y coordinate.
Pick three of the points and color one red, one green, and one blue. Let be the number of the red point, the number of the green point, and the number of the blue point. The coloring must satisfy and at the same time.
Given the coordinates of the points, write a program that counts the colorings satisfying both conditions.
Input
The first line contains N. Each of the next N lines contains the coordinates and of one point, separated by a space. (, )
Output
Print the number of colorings that satisfy the conditions. This value can exceed the range of a 32-bit integer.