ujjwalmittal's blog

By ujjwalmittal, history, 5 years ago, In English

i a unable to figure it out why my code is giving runtime error on test 1 on codeforces though on my ide it is working fine ??? it is showing runtime error Exit code is -1073741819.. here is my submission link https://codeforces.me/contest/962/submission/74191458

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

| Write comment?
»
5 years ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

https://ideone.com/1eOkBs

Error message

Error in next lines:

auto it1=mp[el].begin();
mp[el].erase(it1);
index1=*it1;
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    could u plz elaborate?? it is running fine on codechef ide

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

      Your program has undefined behavior: dereference of singular iterator (using *it1 after erasing data of it1). When your program has undefined behavior, compiler can do what he want. Codechef chose ignore this, your ide chose ignore this. Codeforces chose punish you.