1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nullptr) {} ListNode(int x) : val(x), next(nullptr) {} ListNode(int x, ListNode *next) : val(x), next(next) {} }; struct cmp1{ bool operator()(ListNode *a, ListNode *b){ return a->val > b->val; } }; struct cmp2{ bool operator()(ListNode *a, ListNode *b){ return a->val < b->val; } }; int main(){ priority_queue<ListNode *, vector<ListNode *>, cmp1> q4; priority_queue<ListNode *, vector<ListNode *>, cmp2> q5; return 0; }
|