关于优先队列重载运算符

struct Item {
    int a, b, c;
    int id;
    int ans;

    explicit Item(int _a = 0, int _b = 0, int _c = 0) : a(_a), b(_b), c(_c) {}
};

struct cmpa {
    bool operator()(const Item &lhs, const Item &rhs) const {
        return lhs.a > rhs.a || (lhs.a == rhs.a && lhs.b < rhs.b)
               || (lhs.a == rhs.a && lhs.b == rhs.b && lhs.c < rhs.c);
    }
};

struct cmpc {
    bool operator()(const Item &lhs, const Item &rhs) const {
        return lhs.c > rhs.c || (lhs.c == rhs.c && lhs.b < rhs.b)
               || (lhs.c == rhs.c && lhs.b == rhs.b && lhs.a < rhs.a);
    }
};

priority_queue<Item, vector<Item>, cmpa> Qin;
priority_queue<Item, vector<Item>, cmpc> Qout;

posted @ 2019-08-22 11:03  liulex  阅读(303)  评论(0编辑  收藏  举报