Hi, codeforces, Getting straight to the point my submission 143634261 failed at system testing and gave me a runtime error at test case 14. I tried searching about it but the only useful resource I was able to find is this blog but my code can't go beyond the limit and can't go negative. So, please help me.
If a = {1, 2} and b = {1, 2}, then both cmp(a, b) and cmp(b, a) return true.
Thanks for helping.
Just a doubt: Shouldn't this will only cause a and b to switch their position whenever they are compared. It should not throw an error for this (speaking from my knowledge about the sort function).
Edit: I checked by removing it and the code worked but I still don't get why it is throwing that error.
Having a bad comparator is undefined behaviour, so it may fail in various ways depending on the sort function implementation. See https://codeforces.net/blog/entry/72525 and https://stackoverflow.com/questions/45929474/why-must-stdsort-compare-function-return-false-when-arguments-are-equal
It's a rather common pitfall. Even though in some cases people get an AC verdict despite a broken comparator and don't have any reason to learn anything.
the comparator must follow these 3 rules: 1. For all x, comp(x,x) is false. 2. For all x and y, if comp(x,y) is true, comp(y,x) is false. 3. For all x, y, and z, if comp(x,y) and comp(y,z) are both true, comp(x,z) must be true.