Need help on a bitmask DP problem

Revision en1, by shakil.ahamed, 2016-12-25 00:12:16

Problem link: http://www.lightoj.com/volume_showproblem.php?problem=1018

Verdict: TLE — O(n^2 * 2^n) solution

Code: http://ideone.com/7JjcIX

I transformed the problem into this. The idea is to given N integer 0 <= N < 2^M where M <= 16, find the minimum number of integer needed to make 2^M-1 by the operation bitwise-OR. My solution is a variation of subset sum as it is the only DP algorithm I know. But, The test cases are huge, 1000. Can you suggest a better approach? Thanks for your attention.

Tags dp, bitmasks, lightoj

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English shakil.ahamed 2016-12-25 00:12:16 555 Initial revision (published)