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
https://ideone.com/1eOkBs
/usr/include/c++/8/debug/safe_iterator.h:270: Error: attempt to dereference a singular iterator.
Objects involved in the operation: iterator "this" @ 0x0x7ffc32868110 { type = gnu_debug::_Safe_iterator<std::_Rb_tree_const_iterator, std::debug::set<long long, std::less, std::allocator > > (mutable iterator); state = singular; references sequence with type 'std::__debug::set<long long, std::less, std::allocator >' @ 0x0x55664c03e078 }
Error in next lines:
could u plz elaborate?? it is running fine on codechef ide
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.