Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- #define int long long
- typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
- signed main()
- {
- ordered_multiset s;
- s.insert(2);
- s.insert(7);
- s.insert(5);
- s.insert(2);
- //i - th
- for(auto i : s)
- cout << i << " ";
- cout << endl;
- int i = 2;
- auto it = s.begin();
- while(i--){
- it++;
- }
- cout << *it << endl;
- i = 2;
- cout << *s.find_by_order(i) << endl; // iterator i-th place
- int x = 5;
- cout << distance(s.begin() , s.lower_bound(x)) << endl;
- int cnt = 0;
- it = s.lower_bound(x);
- while(it != s.begin()){
- cnt++;
- it--;
- }
- cout << cnt << endl;
- cout << s.order_of_key(x) << endl; // s.lower_bound(x) - s.begin()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement