Unable to find the error in my solution for RGAND

I recently learnt that if you have any error in your solution it can be found by generating random input and comparing its output with a correct solution(even if it is a brute force one) until there is a mismatch. I got a WA on my submission (https://www.codechef.com/viewsolution/29081920) for RGAND and after the contest ended, I took a correct solution (karpovich’s submission)(https://www.codechef.com/viewsolution/29082410) and tried to repeat the above said procedure but I was unable to find any difference in the outputs. Can someone please let me know any test case that my code fails to give the correct output.


100000000000000000 1000000000000000000
1000000000000000000 1000000000000000000

1 Like

Thanks a lot for your help abhinav. I now understood the error occured when I used
which when i=31 was first converted to a negative integer and then to a long long integer.
Changing (1<<i) to (1ll<<i) fixed the issue.

1 Like