Can you please provide some corner test cases. I am getting WA.
How will u have a number with 100 bits??
Are doing it using array, then you can’t perform bitwise operators directly??
What if a person doesn’t have that TSHIRT ?
The pseudo code accesses dp[mask][tid].
dp has size dp[1<<N][N] where N<11 but tid < 101. Here tid can clearly go outside the limit of the array.
In the actual code you have created array dp[1025][109]
Shouldn’t the expression in line 4 be -
if mask==(2**N)-1:
Also, the dp[][] array should be -
const int K=101;
dp[1<<N][K];
because clearly, we need the TSHIRT no. as the second index, not the user no.
good tutorial … helped a lot
I think the complexity will be O( 2^N * K * N ) .
Morover, if someone wants to see a backward implementation of this problem, can check my submission .
Also, One can check a very similar problem ASSIGN on spoj.
This problem + ASSIGN on spoj gives you two or more ways of solving this problem.
In general when we need a set we can have options !! That is a very beautiful thing! One should learn that rather learn should feel that !!
dTD9nL - Online C++ Compiler & Debugging Tool - Ideone.com Can someone tell me where im going wrong ?
This site might be useful Bitmasking and Dynamic Programming | Set 1 (Count ways to assign unique cap to every person) - GeeksforGeeks
in the solution if (mask == p) then 111 is returned and if not 011 is returned where p is all set mask . Can somebody tell me why?
Because there no mention about it in the pseudo code
The number just needs 10 bits for the number of people. The tee shirt numbers are not part of the bitmask.
Then don’t recurse. The code isn’t present, but the idea is represented as a comment.
can any one tell me bottom up approach to this problem. it would be great help.
can anyone tell me bottom up approach to this problem. i m not able to figure out how to define state in this problem.
He is definately oing 2 have a shirt read the question carefully,it says each person has atleast 1 shirt
Can pls someone tell how to take the input.Like in the first case,how would we know if a person has 2 or 3 tshirts.How do i know that the next tshirt is for another guy.