Can you explain the output

What will be the output of following C++ code?

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
struct Compare
{
bool operator()(pi const & a, pi const & b)
{
if(a.second < b.second)
{
return true;
}
else if(a.second > b.second)
{
return false;
}
else
{
if(a.first > b.first)
{
return true;
}
return false;
}
}
};
int main()
{
priority_queue<pi , vector, Compare>q;
q.push({1, 5});
q.push({5, 15});
q.push({7, 15});
q.push({10, 2});
q.push({1, 10});
cout<<q.top().first<<" "<<q.top().second<<endl;
return 0;
}

It must be
5 15

Because:
if(a.second < b.second)
{
return true;
}
Due to this a max heap will be formed based on second element.
When second element is same as in ({5, 15}) and ({7, 15}), the else part would be executed
Since in else part:
if(a.first > b.first)
{
return true;
}
So a min heap based on first element would be formed.
So…at the end the top of the heap would have {5, 15}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.