Here's the problem:
The same codes are having different verdicts here,
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?
Your comparator doesn't meet the compare requirements. Shortly,
cmp(A,B)
should returntrue
only if object A is strictly less than object B. In particular,cmp(A, A)
must always returnfalse
. 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
Doesn't cmp(A, A) return false in C++17(64)? I got AC verdict.
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.
UB can also result in time travel.
This blog might help https://mirror.codeforces.com/blog/entry/70237