C++14: cin vs scanf

Here is the problem statement.

this code with cin gives AC, whereas this code with scanf gives WA in C++14.

Why is this happening?

1 Like

This is quite odd o.O

Looking at it briefly they look identical in the logic used, and running quite a bit of random tests on it locally I’ve not found any case where they differ. So I’ve got no clue why this would happen. Just to rule out any logic differences between the programs you could try to rewrite the cin solution to use scanf and vice-versa.

https://www.codechef.com/viewsolution/18334397

https://www.codechef.com/viewsolution/18334406

1 Like

There was one test file which didn’t satisfy the constraints. It had some integer with more than 20 digits. That’s probably the issue, with cin and scanf probably treating it differently. We’ve deleted that file. Hope things are ok now.
Sorry for the inconvenience.

2 Likes