WA in SANSKAR

I am getting WA in last test case of SANSKAR…

Here is my algo…

I have used simple back tracking and recursion along with dp(by the means of map itachi) to find whether a number is not found previously or not in the same derivation tree…

I am getting WA only in the last test case

Can anyone tell me where my code is wrong

Or provide the test cases for which my code gives WA

Thnx for the help

http://www.codechef.com/submit/complete/446994-8759--548f1837882bb

1
1 8
0

try this test case , it should output no , but yours giving yes .

Your code fails for the test case 1 1 2 0 . Point here is a sanskar with zero intensity and no sanskar are not the same things. Your gode gives yes for this test case, while the answer is no. See here: 7mjBOX - Online C++ Compiler & Debugging Tool - Ideone.com