VasuOberoi's blog

By VasuOberoi, history, 3 years ago, In English

PROBLEM LINK:https://mirror.codeforces.com/contest/1468/problem/C

When i am taking int to long long the verdict is :RUNTIME ERROR ON TEST 39 When i am taking int:Its getting accepted

Runtime Error submission Link:https://mirror.codeforces.com/contest/1468/submission/126266278

Accepted Solution Link:https://mirror.codeforces.com/contest/1468/submission/126266726

WHAT IS THE CAUSE OF RUNTIME WHEN I AM TAKING INT TO LONG LONG.Please explain.

I am always take my int to long long.After this incident i will be scared to take int to long long.Please Help

THANKS IN ADVANCE

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

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

If I had to guess, your runtime error could be caused by erasing the beginning of for_monocarp before dereferencing it (calling for_monocarp.erase(it); before int ss = *it;). Erasing an iterator invalidates it, so in general, dereferencing is no longer possible. However, you may have simply been lucky and had no issues from this with your second version.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Is this possible what u are saying same error can also happen while taking int to int32_t

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Assuming that is actually what is causing the error, it should be possible with int32_t as well, but undefined behavior like that is very unpredictable, so you may have simply lucked out in that case.