Getting WA in C++ but AC in Python

Please dont suggest to check the algorithm carefully because, I know my solutions are correct since when implemented in python I got AC.

But still unable to get AC for chef-jumping and rrstone in C++.

What should I check?

The reason, might spoil the fun of solving the problem for others. So, I wont tell it now.
Will get back to this after the contest is over.

Anyways, it is obvious, isn’t it? If the algorithm is correct, but implementation in one language says something is wrong, then there is something specific for that language that is causing this?

1 Like

I am printing the output in exact same form as python… and even know that “other” thing. but still no luck.

You are right… we will discuss after the contest. its not like i am stuck on these solutions… but i am just bummed. and what if it happens again?

@swapniel99,

You got a wrong answer because of integer overflow problems.

You were using the data type long which is a 32-bit integer, which can hold integers upto ~109. For numbers as large as 1018, you should be using long long, which is the 64-bit integer data type.

Now, Python obviously have arbitrary precision integers. So, there will be no overflows.

For a problem as simple as this, if one language gives correct answer, while the other says wrong answer, then the only possible explanation is something that is language-specific. And it turned out that it is the case so here.