-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomparators.cpp
More file actions
49 lines (41 loc) · 939 Bytes
/
Copy pathcomparators.cpp
File metadata and controls
49 lines (41 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
struct comp {
bool operator()(const pair<int, int>& a, const pair<int, int>& b) {
return a.second > b.second;
}
};
struct edge {
int u, v, w;
bool operator<(const edge& e) const {
return w > e.w;
}
};
struct node {
int x;
bool operator<(const node& n) const {
return x > n.x;
}
};
int main() {
priority_queue<pair<int, int>, vector<pair<int, int>>, comp> pq;
pq.push({1, 2});
pq.push({2, 1});
while (!pq.empty()) {
cout << pq.top().first << " " << pq.top().second << endl;
pq.pop();
}
set <edge > st;
st.insert({1, 2, 3});
st.insert({2, 3, 4});
for (auto& x : st) {
cout << x.u << " " << x.v << " " << x.w << endl;
}
set <node> st2;
st2.insert({1});
st2.insert({2});
for (auto& x : st2) {
cout << x.x << endl;
}
return 0;
}