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

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

Can anyone help me indentifying why my code is giving runtime error for this following code in Problem G: (https://codeforces.com/contest/1971/submission/260600724)

Edit: Got the issue and got AC but could not understand the reason

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

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

in sort, you should use return a<b;, but not return a<=b, which give RTE or TLE or MLE or somethingelse except AC.

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

    Oh Nice, it got accepted. But why "return a <= b" gave the RTE error ?

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

      https://en.cppreference.com/w/cpp/algorithm/sort

      comparison function object (i.e. an object that satisfies the requirements of Compare) which returns ​true if the first argument is less than (i.e. is ordered before) the second.

      Just because the standard says so. There is no guarantee what will happen if you return less or equal.

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

        Oh thanks. Went through the link provided. Still cannot figure out the exact reason for the runtime error. But still, thanks for helping.

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

Auto comment: topic has been updated by Fume (previous revision, new revision, compare).