I_am_prince_VEGETA's blog

By I_am_prince_VEGETA, history, 3 years ago, In English

Here's the problem:

166A - Ранклист

The same codes are having different verdicts here,

submission:113596205

113554437 (WA on test 15)

113536634 (WA on test 15)

Accepted one is in C++17(64). Rest two are in C++17 and C++14. I use sublime text and Your text to link here... Both gives correct output for test 15 in C++14 and other versions. But This problem's verdict and custom invocation shows me wrong. I wonder what's the deal here?

| Write comment?
»
3 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Your comparator doesn't meet the compare requirements. Shortly, cmp(A,B) should return true only if object A is strictly less than object B. In particular, cmp(A, A) must always return false. Otherwise it will lead to undefined behavior and that's exactly what you've got.

So just change 1 symbol and it turns into AC: 117936962

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Doesn't cmp(A, A) return false in C++17(64)? I got AC verdict.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It does not. If an object doesn't compare equal to itself, you have UB, and then you're doomed: your code may in theory work as expected, produce RE or WA or TL or put your computer on fire. Never rely on UB.

»
3 years ago, # |
  Vote: I like it +19 Vote: I do not like it