Блог пользователя ay2306

Автор ay2306, история, 6 лет назад, По-английски

I was solving a question on codeforces. Sample test case are giving me correct answer in terminal but it is different in codeforces submission.

Link to submission. My terminal gives me a correct answer of

yes 1 3

but it is no in codeforces. How do I debug in such a situation?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

Look for undefined behavior. In your case, it should be this line: for(int i; i < n; ++i){. You need to initialize the counter first. Corrected, it passes through 6 tests: 39749555.