I have a basic doubt, in that I am trying to figure out the versatility of priority_queue STL in C++.
I know that priority queue by default is actually a max_heap. I also am aware that it can be modified in the following way to create a min_heap:
priority_queue <int, vector<int>, greater<int> > pq;
What I aim to achieve, is that I want to create a priority_queue <pair <int,int> pq, such that heap is a max_heap for the first element in the pair, and it is a min_heap for the second element in the pair. For example, on inserting the following pairs:
(2,4) (1,5) (1,6)
The output when elements are displayed is as follows:
(2,4) (1,5) (1,6) By default, the output would have been:
(2,4) (1,6) (1,5) Is it possible? If yes, then how?
Thank you in advance.