优先队列

Posted guaguastandup

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了优先队列相关的知识,希望对你有一定的参考价值。

优先队列

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;

以上是关于优先队列的主要内容,如果未能解决你的问题,请参考以下文章