Today while solving [this](http://mirror.codeforces.com/contest/802/problem/B) 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://mirror.codeforces.com/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;↵
}↵
~~~~~↵
↵
2. http://mirror.codeforces.com/contest/802/submission/27695705↵
↵
verdict : AC↵
↵
compare function : ↵
↵
~~~~~↵
bool operator < ( const data& b ) const {↵
if(pos == b.pos) {↵
return num < b.num;↵
}↵
return pos < b.pos;↵
}↵
~~~~~↵
↵
3. http://mirror.codeforces.com/contest/802/submission/27695712↵
↵
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?
↵
I made three identical submissions only with slight changes in compare function to see it's behavior.↵
↵
↵
**My three submission:**↵
1. http://mirror.codeforces.com/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;↵
}↵
~~~~~↵
↵
2. http://mirror.codeforces.com/contest/802/submission/27695705↵
↵
verdict : AC↵
↵
compare function : ↵
↵
~~~~~↵
bool operator < ( const data& b ) const {↵
if(pos == b.pos) {↵
return num < b.num;↵
}↵
return pos < b.pos;↵
}↵
~~~~~↵
↵
3. http://mirror.codeforces.com/contest/802/submission/27695712↵
↵
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?