Box intersection volume
InterviewTime limit1sMemory limit256 MB
Compute the volume shared by N axis-aligned boxes by intersecting their x, y, and z ranges.
- Level
Easy1 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
There are boxes in three dimensional space. Each box is given by two opposite corners, and every face is parallel to a coordinate plane.
Write a program that computes the volume of the region covered by all boxes at once, that is, the volume of their intersection.
Input
The first line contains the number of boxes ().
Each of the next lines contains six integers , , , , , separated by spaces. The first three are the coordinates of one corner and the last three are the coordinates of the opposite corner. All coordinates are between and , and , , .
Output
Print the volume of the intersection of the boxes on the first line. If the intersection is empty or has no thickness, print .