Блог пользователя skittles_99

Автор skittles_99, история, 8 лет назад, По-английски

Hi Guys,I will always stuck at this type of problems.Here are some problems that involves domino tiling.
Problem1
Problem2
I found some tutorials on stackoverflow and on google search but I am unable to get it.
Is there any method to solve recurrence for this type of problem or some resources to learn will be helpful :)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

This is a classic problem of dynamic programming with bit masks.

The first problem you are trying to fill a 4xN board, this can be done iterating over columns, notice that if you are going to fill column K, you need to know the state of column K-1, K-1 may be full or may have some holes, for each hole you need to place an horizontal domino in column K, the trick is to have a bitmask representation for the state of column K-1 and iterate over all possible valid bitmasks for column K.

In the second problem N*M <= 100, this means than min(N, M) <= 10, this allows you to use the same approach as before.