1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main(){ ordered_set<int> s; s.insert(1); s.insert(2); s.insert(3); s.insert(4); cout << s.order_of_key(1) << endl; cout << s.order_of_key(2) << endl; cout << s.order_of_key(3) << endl; cout << s.order_of_key(4) << endl; cout << *s.find_by_order(0) << endl; auto it = s.find_by_order(1); cout << *it << endl; }
|