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
If I had to guess, your runtime error could be caused by erasing the beginning of
for_monocarp
before dereferencing it (callingfor_monocarp.erase(it);
beforeint 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.Is this possible what u are saying same error can also happen while taking int to int32_t
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.
I just tested your Runtime Error code with
for_monocarp.erase(it);
moved afterint ss = *it;
and it worked fine, so it seems that was actually the problem. Here is the link: https://mirror.codeforces.com/contest/1468/submission/126456206Thank u very much for clearing my doubt