Advertisement
arnobkumarsaha

Policy Based Data Structure

Sep 4th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #include<ext/pb_ds/assoc_container.hpp>
  4. #include<ext/pb_ds/tree_policy.hpp>
  5. using namespace __gnu_pbds;
  6. #define ll long long
  7. typedef tree<
  8. pair<ll,ll>,
  9.      null_type,
  10.      greater<pair<ll,ll> >,
  11.      rb_tree_tag,
  12.      tree_order_statistics_node_update> set_t;
  13.  
  14. int main()
  15. {
  16.     set_t arnob;
  17.     arnob.insert(make_pair(5,10));
  18.     arnob.insert(make_pair(1,9));
  19.     arnob.insert(make_pair(7,9));
  20.     arnob.insert(make_pair(5,7));
  21.     for(auto x : arnob){
  22.        cout<<x.first<<' '<<x.second<<endl;
  23.     }cout<<endl;
  24.  
  25.     pair<ll,ll> pp = *(arnob.find_by_order({2}));
  26.     cout<<pp.first<<' '<<pp.second<<endl;
  27.  
  28.     cout<<arnob.order_of_key(pp)<<endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement