Minimum exact cover of grid with squares; extra cuts

前端 未结 5 2038
迷失自我
迷失自我 2020-12-16 10:50

This problem appeared in a challenge, but since it is now closed it should be OK to ask about it.

The problem (not this question itself, this is just background info

5条回答
  •  北海茫月
    2020-12-16 11:20

    Dynamic programming: choose a cell (any cell will do), compute all valid squares that cover it (that is, that only cover the current cell and other cells in the grid). For each such square, recursively get the minimum coverage value for the remaining area (grid minus the square), and then choose the minimum value from those (the result is that value + 1). To make things faster, try to choose a cell which has the fewest valid covering square in each level of the recursion (thus reducing the number of recursive calls in each level).

    Simple really.

提交回复
热议问题