fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define debug(v) \
  5.   cerr << "Line(" << __LINE__ << ") -> " << #v << " = " ;
  6. #define dbx(x) debug(x); cerr << x << "\n";
  7. #define dbg(x) debug(x); cerr << "{ "; for(auto &e : x) cerr << e << ", "; cerr << "} \n";
  8.  
  9. // Code
  10. #include<ext/pb_ds/assoc_container.hpp>
  11. #include<ext/pb_ds/tree_policy.hpp>
  12. using namespace __gnu_pbds;
  13. template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  14.  
  15. const ll N = 1e6+10, MOD = (ll)1e9+7, OO = (ll)1e17+10;
  16.  
  17. void solve(){
  18.  
  19. o_set<int>se;
  20. se.insert(1);
  21. se.insert(2);
  22. cout << *se.find_by_order(0) << endl; ///k th element
  23. cout << se.order_of_key(2) << endl; ///number of elements less than k
  24.  
  25. }
  26.  
  27. int main()
  28. {
  29. ios_base::sync_with_stdio(0);
  30. cin.tie(0);
  31.  
  32. ll tc = 1; // cin >> tc;
  33. for(int t = 1 ; t <= tc ; t ++){
  34. solve();
  35. }
  36.  
  37. return 0;
  38. }
  39.  
  40. /*
  41.  
  42. */
  43.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
1
1