-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolicy_base_DS.cpp
More file actions
30 lines (24 loc) · 944 Bytes
/
Copy pathpolicy_base_DS.cpp
File metadata and controls
30 lines (24 loc) · 944 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
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//less_equal used for multiset where st.order_of_key(x) gives the lower_bound of x
// it will not work for erase element. so for erase element better to use ordered set as pair
*/
#define FasterIO ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
ordered_set st;
int x=*st.find_by_order(4);
//find 4th element in orderd set
int y=st.order_of_key(4);
//number of element less than 4 in orderd set
if (st.find(4) != st.end())
st.erase(st.find(4));
//delete 4 if exist in orderd set
return 0;
}