优先队列

优先队列

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;
posted @ 2020-03-28 00:07  瓜瓜站起来  阅读(96)  评论(0编辑  收藏  举报