priority_queue 排序

两种写法等价(都是按照 堆顶是 x小的)但是在did内直接重载快得多!!!

struct did{
	int x,y;
	bool operator<(const did& t)const{
		return t.x<x;
	}
};
struct cmp{
	bool operator()(did &a,did &b)
	{
		return a.x>b.x;
	}
};
priority_queue<did>q;

priority_queue<did,vector<did> ,cmp>q;
posted @ 2023-04-27 16:27  N0zoM1z0  阅读(29)  评论(0)    收藏  举报