Intellectual Implementation
Time limit6sMemory limit512 MB
Count the triples of axis-parallel rectangles, with all coordinates distinct, where no two rectangles in a triple share any point.
- Level
Hard9 of 10
- Topics
- Math, Segment tree, Sorting
- Solved
- No attempts yet
Problem
There are rectangles on the coordinate plane, with sides parallel to the coordinate axes. The -th rectangle covers all points with and .
For simplicity, for every , we have , , , , , .
Count the number of triples with for which the -th, -th, and -th rectangles are pairwise disjoint (every pair of them has no common points).
Input
The first line contains a single integer (), the number of rectangles.
Each of the next lines contains four integers , , , (, ), describing the -th rectangle.
It is guaranteed that for every , we have , , , , , .
Output
Output the number of triples with for which the -th, -th, and -th rectangles are pairwise disjoint.