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

Автор yshen94, 10 часов назад, По-английски

really curious about the performance difference bewteen array and vector.

for 2023A — Concatenation of Arrays,

I passed the test using array as in #287237470 while failed the test using vector as in #287234748. The error shows "exit code: -1073741819 (STATUS_ACCESS_VIOLATION), checker exit code: 0, verdict: RUNTIME_ERROR"

maybe I am quite new in Codeforces. will be digging deeper into the performance difference.

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

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

Your cmp function is broken. The comparator should return false on elements that you consider equivalent: it should be return x.x+x.y < y.x+y.y;.

That is probably part of the reason for the runtime error, not some minute performance difference.

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

    You are right, appreciate your explanation. but why cannot I have an equivalent sign?

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

      C++ comparator should define the < sign. Using this, we automatically get the other two cases: x > y = !(x < y) and x == y = !(x < y) && !(x > y)

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

I made the same mistake that my comparator returns true if elements are equivalent. After receiving a runtime error I passed the code for ChatGPT for debugging. It immediately pinpointed the bug.. Most of the time, AI tools help me debug really quickly.