Strange behaviour for vector<> in GNU C++11

Revision ru1, by LLI_E_P_JI_O_K, 2017-02-26 16:06:53

Hello, guys!

Today in Codeforces round 402 (Div 2) I tried to challenge this solution with a test:

5 2
1 1 1 1 1
5 5 5 5 5

So, as you can see in the code this cycle has no any check for reaching the end of the vector "v":

...
while (v[j].first<0||j<r)
{
sum1+=v1[v[j].second];
j++;    
}
...

Obviously "j" will be out of the vector for such testcase and we will check whether "v[5].first<0" or not, but no any Runtime Error when trying to get nonexistent element of vector. So, as you can understand, challenge was unsuccessful. Why?

Tags vector, g++, bound overflow, runtime error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian LLI_E_P_JI_O_K 2017-02-26 16:06:53 703 Первая редакция (опубликовано)