#5042. Problem 2. Farmer John's Cheese Block
Problem 2. Farmer John's Cheese Block
Problem 2. Farmer John's Cheese Block
USACO 2024 December Contest, Bronze
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 will carve out the by by block of cheese extending from integer coordinates to , where . It is guaranteed that there will exist a by by block of cheese at the location FJ carves. Since FJ is playing Moocraft, gravity does not cause parts of the cheese to fall if cheese below is carved.
After each update, output the number of distinct configurations that FJ can stick a by by brick in the cheese block such that no part of the brick overlaps with any remaining cheese. Every vertex of the brick must have integer coordinates in the range for all three axes. FJ may rotate the brick however he wants.
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains and .
The following lines contain , , and , the coordinates to be carved.
OUTPUT FORMAT (print output to the terminal / stdout):
After each update operation, output an integer, the number of configurations.
SAMPLE INPUT:
2 5 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0
SAMPLE OUTPUT:
0 0 1 2 5
After the first three updates, the brick spanning does not overlap with the remaining cheese, so it contributes toward the answer.
SCORING: Inputs 2-4: and Inputs 5-7: and Inputs 8-16: No additional constraints
Problem credits: Chongtian Ma, Alex Liang