Movers
Time limit1sMemory limit128 MB
For each box in order, decide whether it can be slid from the open left side to its destination without overlapping placed boxes or walls, and list the rejects.
- Level
Hard8 of 10
- Topics
- Geometry, Simulation, Implementation, Greedy
- Solved
- No attempts yet
Problem
A manager in charge of a large warehouse expects many boxes to be delivered for storage.
The warehouse is a rectangle whose bottom-left corner is at and whose top-right corner is at . Three of its sides are walls; the left side (the one lying along the -axis) is open.
To move a box to its assigned storage spot, the movers may push it across the warehouse floor, slide it along the side of another box, or carry it without touching any other box or any wall. Boxes are never rotated, and a box must never overlap another box or a wall (merely touching is allowed). Once a box has been set down in its assigned area, it can never be moved again.
If a box cannot be moved to its destination, it is rejected; a rejected box is taken away and does not obstruct the placement of any later box.
Input
The first line contains the number of test cases.
Each test case begins with a line containing three integers , , and , where is the number of boxes. Each of the next lines contains five integers ID X Y W H, separated by single spaces:
ID— a unique identifier for the boxX,Y— the coordinates of the bottom-left corner of the box at its destinationW,H— the width and height of the box
Boxes are processed in the order given.
Constraints:
Output
For each test case, output a line beginning with Case followed by the test case number (starting from ). Then, for every box that cannot be placed, output a line containing Reject and the box's ID, separated by a single space. Rejected boxes must be listed in the same order in which they appear in the input.