Farmer John's Cheese Block
InterviewTime limit2sMemory limit2048 MB
After each removal of a unit cube from an N x N x N block, count the 1 x 1 x N bricks that still fit in the remaining cheese.
- Level
Medium4 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
Farmer John has a block of cheese in the shape of a cube. It lies on the 3-dimensional coordinate plane, extending from to (). Farmer John will perform a series of () update operations to his cheese block.
For each update operation, FJ carves out the block of cheese extending from integer coordinates to , where . It is guaranteed that a block of cheese exists at the location FJ carves. Since FJ is playing Moocraft, gravity does not cause parts of the cheese to fall if the cheese below is carved.
After each update, output the number of distinct configurations in which FJ can stick a brick into the cheese block such that no part of the brick overlaps any remaining cheese. Every vertex of the brick must have integer coordinates in the range on all three axes. FJ may rotate the brick however he wants.
Input
The first line contains and .
Each of the following lines contains , , and , the coordinates to carve.
Output
After each update, output one integer: the number of configurations.
Hint
After the first three updates, the brick spanning does not overlap the remaining cheese, so it contributes to the answer.
