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

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

I have learn DP recently. I am practicing DP in this OJ. Now, I am stuck on this problem.

In this problem I have to find the maximum summation of cells such that any two cells don't have the same row or column.

So, I will use recursion from top of the matrix. When using recursion I got to check if that cell is available or not, i.e. that cells row and column has not previously been used. How can I do that?

Теги #dp
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
9 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +4 Проголосовать: не нравится

N ≤ 16, so you can use bitmasks to store which columns are available. Go row by row and each time select one column among the ones available, updating DP as necessary. I'll post code if necessary.

As a side note, this problem can also be solved much faster with min-cost max-flow, though it's obviously overkill.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How can i solve this problem recursively without bitmask. Actually I am beginner at dp and practicing from lightoj.