Question: 2 0 2 0 Time limit: 3.000 seconds A number of boxes is to be moved in a warehouse. The warehouse can be modeled as
Time limit: 3.000 seconds A number of boxes is to be moved in a warehouse. The warehouse can be modeled as a grid wher each square is the equal to the size of a box. Consider the model below: ('B' = box to be moved, empty square, 'X' = position a box should occupy after the move, #' = obstacle) BBBB.... .###... .XX#...X .#. A box may be moved to any of its four neighboring squares, assuming this square is empty (that is not occupied by another box or an obstacle). To move a box takes one unit of time, and only one bo may be moved per time unit. Your task is to determine the least amount of time to move all boxes to their destination squares. You may assume that a solution exists. Number of boxes will be no mor than 15. Input The first line in the input contains the number of test cases (at most 20). Each case starts with a lin containing two integers, the height (1 h 40) and width (1 w 40) of the grid. Then follows lines, each containing w characters, describing the grid in the format above. Output For each test case, output a line containing a single integer: the minimum number of time units to move all boxes. Sample Input 1 58 BBBB.... . ### . . .XX# . . .#. . Sample Output 20
Step by Step Solution
There are 3 Steps involved in it
To solve this problem you need to calculate the minimum time to move boxes from their initial positions to their respective target positions You can m... View full answer
Get step-by-step solutions from verified subject matter experts
