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

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

Good Day everyone . Can anyone please tell me the process how to solve this problem . Thanx in advance :)

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

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

DP with bitmasks. You can use two bitmasks, one for which numbers you have taken so far from the permutation, and the other to indicate which of these numbers are considered in the LIS. You need to update these two masks accordingly whenever you add the next number. Complexity: O(n * 3^n) since the LIS mask is always a subset of the former.