summaryrefslogtreecommitdiff
path: root/content/datastructures/sparseTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'content/datastructures/sparseTable.cpp')
-rw-r--r--content/datastructures/sparseTable.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/content/datastructures/sparseTable.cpp b/content/datastructures/sparseTable.cpp
index b3f946e..5455ef5 100644
--- a/content/datastructures/sparseTable.cpp
+++ b/content/datastructures/sparseTable.cpp
@@ -6,17 +6,17 @@ struct SparseTable {
return a[lidx] <= a[ridx] ? lidx : ridx;
}
- void init(vector<ll>* vec) {
- int n = sz(*vec);
- a = vec->data();
+ void init(vector<ll> &vec) {
+ int n = ssize(vec);
+ a = vec.data();
st.assign(__lg(n) + 1, vector<int>(n));
- iota(all(st[0]), 0);
+ iota(begin(st[0]), end(st[0]), 0);
for (int j = 0; (2 << j) <= n; j++) {
for (int i = 0; i + (2 << j) <= n; i++) {
st[j + 1][i] = better(st[j][i] , st[j][i + (1 << j)]);
}}}
- int queryIdempotent(int l, int r) {
+ int query(int l, int r) {
if (r <= l) return -1;
int j = __lg(r - l); //31 - builtin_clz(r - l);
return better(st[j][l] , st[j][r - (1 << j)]);