diff --git a/content/data-structures/OrderStatisticTree.h b/content/data-structures/OrderStatisticTree.h index 8928bc9..b5fe5c7 100644 --- a/content/data-structures/OrderStatisticTree.h +++ b/content/data-structures/OrderStatisticTree.h @@ -8,21 +8,16 @@ * To get a map, change \texttt{null\_type}. * Time: O(\log N) */ -#pragma once - -#include /** keep-include */ +#include using namespace __gnu_pbds; -template -using Tree = tree, rb_tree_tag, - tree_order_statistics_node_update>; +// find_by_order(x): return iterator to k-th largest element(count from 0) +// order_of_key(x): number of element strictly less than x -void example() { - Tree t, t2; t.insert(8); - auto it = t.insert(10).first; - assert(it == t.lower_bound(9)); - assert(t.order_of_key(10) == 1); - assert(t.order_of_key(11) == 2); - assert(*t.find_by_order(0) == 8); - t.join(t2); // assuming T < T2 or T > T2, merge t2 into t -} +typedef tree< + int, + null_type, + less, + rb_tree_tag, + tree_order_statistics_node_update +> ost;