RishiC11's blog

By RishiC11, history, 8 months ago, In English

Hello Codeforces, I was trying to solve the question : Question. I tried to solve it in a knapsack dp kind of manner. It does not show on what testcase I am going wrong , infact it does not show any testcases apart from the sample test cases. so it's my kind request if anybody can help me regarding this question

Code

I am getting WA on testcase 2. I am unable to think of any counter test case or what I am doing wrong. It would be really helpful if somebody could help me regarding this question . Thank you in advance.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By RishiC11, history, 11 months ago, In English

Hello Codeforces, I came across an interesting error while solving this problem : https://codeforces.me/contest/1950/problem/G which I am not able to understand as to why this is happening?

https://codeforces.me/contest/1950/submission/255101098 (This solution did not get accepted but gave runtime error) https://codeforces.me/contest/1950/submission/255101528 (This solution got accepted)

Note there is very little difference between the two

In the first solution I have initialized vector as : vector<vector<int>>dp(n,vector<int>((1<<n),-1));

In the second solution I have initialized vector as : vector<vector<int>>dp((1<<n),vector<int>(n,-1));

I really don't understand what is causing this error. Any help would be appreciated. Thank you !

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it