优先级队列priority_queue 自定义比较函数cmp
便捷方法
struct Node
{
int x,y;
bool operator <(Node a) const { return y < a.y; }
bool operator >(Node a) const { return y > a.y; }
};
priority_queue<Node> A; //大根堆
priority_queue<Node, vector<Node>, greater<Node> > B; //小根堆
常用方法
struct cmp{
bool operator()(Node a,Node b) { return a.val > b.val; }
};

浙公网安备 33010602011771号