题目描述
Problem Description
Given the positions of $n$ rectangular parallelepipeds in a three-dimensional space, determine how many pairs of these rectangles have overlapping parts. (A single point of intersection is also considered an overlap.)
Input Format
The first line of input contains an integer $n$, representing the number of rectangles.
The next $n$ lines each contain six integers. The first three integers represent the coordinates of the bottom-left vertex of the rectangle, and the last three integers represent the coordinates of the top-right vertex of the rectangle.
Output Format
Output a single integer on one line, representing the number of overlapping pairs of rectangles.
Sample Input and Output
Sample Input #1
3
1 1 1 1 3 3
1 3 3 1 6 6
1 4 4 1 5 5
Sample Output #1
2
Sample Input #2
3
15 10 10 15 20 20
10 15 10 20 15 20
10 10 15 20 20 15
Sample Output #2
3
Sample Input #3
5
4 4 5 4 3 2
5 3 2 4 3 1
5 4 3 1 1 3
1 4 3 1 5 4
5 5 4 5 4 2
Sample Output #3
4
Notes
Data Size and Constraints
For $100\%$ of the data, it is guaranteed that $1 \le n \le 10^5$, and the coordinates range between $1$ and $999$. Each rectangle is parallel to one of the coordinate planes.
Note
This problem is translated from COCI2006-2007 CONTEST #6 T6 PROSTOR.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分