Today I read a blog that says: "In C++, comparator should return false if its arguments are equal." I don't really understand it (as I am a newbie to CP), can anyone explain for me about it? Btw, I makeup this piece of code: (g++14)
#include <bits/stdc++.h>
using namespace std;
int main() {
int a = 1, b = 1;
if((a < b) == true) cout << 1;
else cout << 0;
return 0;
}
I expected it to print out "0", but it print nothing instead. Can anyone explain those? Any help is appreciated, thanks to all of you!
PS: Sorry about my bad english
Auto comment: topic has been updated by h1a4c3k (previous revision, new revision, compare).
When I run it in custom invocation, I get 0. The issue might be that you aren't flushing.
I flushed it and it worked! Thanks for your answer :)
To extend the answer I am mostly sure that you have seen such statement in sorting-kinda blog. Then, indeed, when we use sort() with out custom comparator it should return false when arguments are equal.
And this renowned blog: https://codeforces.com/blog/entry/70237
Thank you, that's right, I got the idea precisely from that blog