Weird Behaviour of Weird Walk Problem

Problem Link: WWALK Problem - CodeChef

Below, I have listed links to my C++ and Python solution to the problem Wierd Walk.
I wanna know why is the same logic giving partial correct result in C++ but giving full AC in Python.

  1. C++ Code (Partially Correct - 30 pts): CodeChef: Practical coding for everyone
  2. Python Code (Full AC - 100 pts): CodeChef: Practical coding for everyone

Can anyone explain what could be wrong?

The answer might be having integer overflow, so use long to store the answer in C++, as there are no such restrictions in python it gives AC.

1 Like

Oh yeah, Thanks! That’s possible, but limits are till 10^5 so I didn’t think it would overflow (since we use addition)! :smiley:

It is possible as maximum value of answer can be order of 10^10.

1 Like

Ok cool! Thank you so much!