Box stacking problem

后端 未结 5 1839
灰色年华
灰色年华 2020-11-28 20:01

I found this famous dp problem in many places, but I can not figure out how to solve.

You are given a set of n types of rectangular 3-D boxes, where

5条回答
  •  旧时难觅i
    2020-11-28 20:28

    I suggest you create a tree (or some sort of tree structure) and parse it with depth search, calculating the max height from the individual vertical "height" (depening on rotation) values.

    This (I think this is the basic approach).

    Details over details:

    The Tree root should be the floor, where any cube fits onto. From there you just create the child nodes of possible next (boxes that can be placed in a certain rotation ontop of the current box) boxes. Recursivly do that for each box and rotation.

    When the tree is build, go through it and calc the total tower heigth from floor to a leaf of the tree.

提交回复
热议问题