One reason of compilation error is b[100]={-1}; This syntax is wrong. If this is corrected then comes Run-time error (even for the sample cases). So you need to implement your size and approach differently for this problem. Feel free to ask if you need more help.
hey b[100]={-1} will assign -1 to only b[0] rest all b[1],b[2]…b[n] will be still 0…if you want to initialize whole array with -1 use fill_n() method…syntax will be fill_n(b,n,-1);
Yes…i solved the problem of initializing the array with -1, but now it is giving runtime error…can u help me solve it.I have taken the appropriate size of the array…as it was mentioned.You can look over to my code: http://www.codechef.com/viewsolution/6069876
Thanks for your support
Have a look at this code. It is the accepted version of your code.Now let me explain the changes i had to make:
If there are 20 elements in a set, then the number of subsets if 2^20 which is close to 1050000. So that means, the size of your b array will br 1050000. The Runtime error you were getting was because of this reason only.
If you still have doubts, don’t hesitate to ask.