Incomparable rectangle pairs
Time limit2sMemory limit512 MB
Count the pairs of rectangles where neither fits inside the other after translation or a 90-degree rotation.
- Level
Medium5 of 10
- Topics
- Sorting, Geometry, Segment tree
- Solved
- No attempts yet
Problem
A rectangle is axis-parallel when its top and bottom sides are parallel to the x-axis and its left and right sides are parallel to the y-axis. From here on, rectangle always means an axis-parallel rectangle.
One rectangle is described by four integers , where is the bottom-left corner and is the top-right corner. This rectangle is called a rectangle.
Two rectangles are incomparable when neither one fits inside the other, even though translation and rotation are allowed. If one fits inside the other, the two rectangles are comparable. Given a list of rectangles, count the pairs of incomparable rectangles.
Input
The first line contains the number of rectangles . ()
Each of the next lines describes one rectangle with four integers , , , separated by a single space. is the bottom-left corner and is the top-right corner. Every coordinate satisfies , , , .
Output
Print the number of pairs of incomparable rectangles on one line.