C++优先级队列

两种自定义优先级方式

struct node
{
    int ind;double l;
    bool operator<(const node& other) const {
        return l < other.l;
    }
};
priority_queue<node>pq;
struct cmp
{
    bool operator()(const node &a,const node &b)
    {
        return a.l>b.l;
    }
};
priority_queue<node,vector<node>,cmp>pq;
posted @ 2025-05-10 19:42  邓佑孤  阅读(6)  评论(0)    收藏  举报