summaryrefslogtreecommitdiff
path: root/datastructures/stlTree.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
committermzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
commit5ab8a5088b729a9953b8dff1b2a985dc8fb2098b (patch)
treeed40d6936c0e9eee40ba62751cbf99ecddbaddc2 /datastructures/stlTree.cpp
parentadabbad9c51cf7cd3874bfde8eac1fbcf84fec10 (diff)
updated tcr
Diffstat (limited to 'datastructures/stlTree.cpp')
-rw-r--r--datastructures/stlTree.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/datastructures/stlTree.cpp b/datastructures/stlTree.cpp
index 6dde73a..29491c4 100644
--- a/datastructures/stlTree.cpp
+++ b/datastructures/stlTree.cpp
@@ -1,14 +1,16 @@
-#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; using namespace __gnu_pbds;
-typedef tree<int, null_type, less<int>, rb_tree_tag,
- tree_order_statistics_node_update> Tree;
+template<typename T>
+using Tree = tree<T, null_type, less<T>, rb_tree_tag,
+ tree_order_statistics_node_update>;
int main() {
- Tree X;
- for (int i = 1; i <= 16; i <<= 1) X.insert(i); // {1, 2, 4, 8, 16}
+ Tree<int> X;
+ // insert {1, 2, 4, 8, 16}
+ for (int i = 1; i <= 16; i *= 2) X.insert(i);
cout << *X.find_by_order(3) << endl; // => 8
- cout << X.order_of_key(10) << endl; // => 4 = min i, mit X[i] >= 10
+ cout << X.order_of_key(10) << endl;
+ // => 4 = min i, mit X[i] >= 10
return 0;
}