优先队列

优先队列

priority_queue<int,vector<int>,greater<int> >q;//小顶堆
priority_queue<int> q;//大顶堆,默认

struct node{
    int c, fc;
    bool operator < (const node& a) const {
        return fc < a.fc;//大顶
    }
}
priority_queue<node> q;

struct node2{//重写仿函数
    bool oprator() (node a,node b) {
        return a,x<b.x;//大顶
    }
}
priority_queue<node,vector<node>,node2> q;
原文地址:https://www.cnblogs.com/guaguastandup/p/12585274.html