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

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

Автор blitzkrieg639, история, 4 года назад, По-английски

Hello everyone, can somebody please tell if there is some issue with the recently added GNU G++17 9.2.0(64 bit, msys 2) compiler? Because it costed me 3 wrong submissions and 10 minutes of time in yesterday's contest. I was submitting the code to the 2nd answer and it gave me WA 3 times, before I changed the compiler to GNU G++17(7.3.0) and it got accepted.

And this is not the first time, this has happened quite a lot of times.

Hence, I wanted to know, if something needs to be imparted into my code, before submitting using that compiler or is it just because of that compiler. Thank you, in advance!

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

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

if (*lower_bound(a, a + n, x) == x)

I think this is undefined if lower_bound() returns a+n.

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

    Yes, it will, if x is not found, I think. If that is the problem, why other compilers are not reporting it?

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

      Undefined behaviour is literally that, undefined. It can give the correct answer, wrong answer, time out, erase your hard disk, anything. Always beware.

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

      The return of lower_bound() is ok, but that array is not initialized at position n. There can be x or any other value.