Please read the new rule regarding the restriction on the use of AI tools. ×

logistic's blog

By logistic, history, 5 years ago, In English

Hello everyone! Lately I stumbled upon a strange issue, when I was solving 1324C - Frog Jumps. I usually wrap my code with a template (defines etc.), so here is submission 73465768, which is getting runtime error on test 1. However when I rewrote my code without this template it got accepted 73465554! Can anyone explain me why the code with a template gets runtime error?

  • Vote: I like it
  • +9
  • Vote: I do not like it

»
5 years ago, # |
Rev. 5   Vote: I like it +9 Vote: I do not like it

The real problem with the first submission is not the template; it is reading the number of test cases t using the scanf macro #define sc(x) scanf("%d", &x) after turning off the synchronization between ios_base and stdio using ios_base::sync_with_stdio(false). All subsequent calls cin >> s inside the solve() function return an empty string.

Check the following output of your code.

https://ideone.com/W7vipx

You just need to replace sc(t) in the main() function with cin >> t.