arunkumar8202's blog

By arunkumar8202, history, 19 months ago, In English

Hello community,

I was trying to solve the question 699C Fence Painting during which I came across a interesting bug in C++ compiler which I couldn't figure out.

I tried to submit to same solution using three different versions of C++ and it gave different result on each run.

C++ 14 : The solution got accepted 173550755

C++ 17 : The solution gave wrong answer on testcase 3 173550802

C++ 20 : The solution got runtime error on testcase 3 173550866

MikeMirzayanov will you please look into the matter or clarify if I have made a mistake. Any kind of help will be appreciated.

  • Vote: I like it
  • -10
  • Vote: I do not like it

»
19 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

.

»
19 months ago, # |
  Vote: I like it +15 Vote: I do not like it

Your code uses undefined behaviour s.lower_bound({v2[i],0}) could be the end iterator which you are not allowed to dereference.