Please read the new rule regarding the restriction on the use of AI tools. ×

Complexity of Bitmask DP

Revision en1, by woolgatherer, 2022-08-21 20:12:54

Here in this problem problem it is said that for n jobs, given is the base price p for each job and an extra charge s for every pair of jobs (i, j), meaning that you have to pay additional s for job i, if and only if job j was completed before, you are to compute the minimum total costs needed to finish all jobs. constraint: 1 <= tc <= 100, 1 <= n <= 14 and base price 1 <= p <= 100000 I noticed some people solved it in O(2^n * n^2) using bitmask dp. As n is 14 so the complexity is approximately 321426400(> 1e8) considering 100 tc as well. How come it passes in 1 sec? An AC Code Sample Input 2 2 10 10 9000 10 3 14 23 0 0 14 0 1000 9500 14 Sample Output Case 1: 30 Case 2: 42

Tags bitmask, dp, complexity

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English woolgatherer 2022-08-21 20:15:06 115 Tiny change: ' <= 100000\nI noticed ' -> ' <= 100000. I noticed ' (published)
en1 English woolgatherer 2022-08-21 20:12:54 858 Initial revision (saved to drafts)