-
Notifications
You must be signed in to change notification settings - Fork 0
/
pbds.cpp
28 lines (17 loc) · 808 Bytes
/
pbds.cpp
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
https://codeforces.com/blog/entry/11080
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//1. using it as ordered set
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// *find_by_order(k-1th)
// order_of_key(val)
// any.erase(val)
//2.using it as ordered multiset
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// Some points to take care for ordered multiset
1. don't use any.find() // it will always return end
2. lower_bound works like upper_bound
3. upper_bound works like lower bound
4. any.erase(any.find_by_order(any.order_of_key(val))); // use this for deleting
https://www.codechef.com/viewsolution/74496520