Does scanf cause any problems?

I submitted 2 solutions to the July Cookoff 2020 problem Even-tual Reduction( in the practice section.
Both the solutions are identical except that the number of testcases taken through the first one is by scanf and in the second one by cin. I got WA for first and AC for second and I couldn’t figure out why. Can anyone explain what’s the error with scanf ? (with scanf) (with cin)

yes i debug and found that n is taking garbage value in scanf. May be because scanf leaves newline character.

1 Like

Thanks a lot for the help !

See e.g. here.

1 Like