一、根据pair的first降序排序,second升序排序
//#include<utility> typedef pair<int,int> P; struct cmp { bool operator()(const P p1,const P p2) { if(p1.first==p2.first) return p1.second>p2.second; else return p1.first<p2.first; } }; priority_queue < P, vector<P>, cmp > que;
1 struct p{ 2 int x,y; 3 }aa[10]; 4 bool cmp(p a,p b) 5 { 6 if(a.x==b.x) return a.y<=b.y; 7 return a.x>b.x; 8 } 9 sort(aa,aa+n,cmp);
原文:https://www.cnblogs.com/xxxinnn/p/12945332.html