Needed Iterative version of bitmask-dp for problem T-Shirts

The editorial of this problem Little Elephant and T-Shirts has the recursive version of bitmask dp. Can anyone please help in having the iterative version of bitmask-dp for the same problem.

Did you check solution by tester? It seems to be what you are looking for.

@lebron I had seen the solution of the tester, but didn’t get his dp-state definition. His final answer is dp[0]. If dp[i] is the number of different possible ways to assign the unique t-shirts to ith set of people, then shouldn’t the final answer be dp[(1<<n)-1]?

Thank you [@lebron][1]. I implemented the code in my way, test cases are running fine, but on submission, it’s producing the wrong answer. Could you please have a quick look at my


[2]?  


  [1]: https://discuss.codechef.com/users/3351/lebron
  [2]: https://ideone.com/sWiLIK

Just inverse 0 and 1 in mask to get it the way you described.

Also, there is a comment right there in the code describing how does it work and what is it about.

1 Like

Can anyone help me? why my code is producing the wrong answer.