Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

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.net/contest/962/submission/74191458

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

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

https://ideone.com/1eOkBs

Error message

Error in next lines:

auto it1=mp[el].begin();
mp[el].erase(it1);
index1=*it1;
  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      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.