Today while solving this problem I faced a strange behavior with set<>.
I made three identical submissions only with slight changes in compare function to see it's behavior.
My three submission: 1. http://codeforces.me/contest/802/submission/27695695
verdict : AC
compare function :
bool operator < ( const data& b ) const {
if(pos == b.pos) {
return num > b.num;
}
return pos < b.pos;
}
verdict : AC
compare function :
bool operator < ( const data& b ) const {
if(pos == b.pos) {
return num < b.num;
}
return pos < b.pos;
}
verdict : WA
compare function :
bool operator < ( const data& b ) const {
return pos < b.pos;
}
Now, it can be my fault but I always have used third option when I have to compare single variable and class contains multiple variables. Also, choosing this always worked out for me, but it's not the case this time.
Now, I want to know what's causing this and why using third option is wrong? Also, what I should do if I only want to compare single or multiple variables but not all variables?