Habitat Range of Fish
Time limit1sMemory limit128 MB
Given up to 50 axis-aligned boxes in 3D, compute the total volume covered by at least K of them.
- Level
Hard8 of 10
- Topics
- Sorting, Divide and conquer, Prefix sum
- Solved
- No attempts yet
Problem
Marine researcher Sanggeun is studying species of fish that live in the East Sea.
The region where each species can live is an axis-aligned rectangular box (cuboid). A fish can move freely anywhere inside its habitat, including the boundary, but it never leaves that range.
A point in the sea is described by three numbers : looking down from above, it is the point located to the east and to the north of a reference point, at depth below the sea surface. Assume the sea is a flat plane.
Write a program that computes the total volume of the region where at least species of fish can live.
Input
The first line contains two integers and . ()
Each of the next lines contains six integers describing the habitat of one fish. (, , )
The habitat of the -th fish is the axis-aligned cuboid whose opposite corners are and .
Output
Print, on a single line, the integer volume of the region where at least species of fish can live.