summaryrefslogtreecommitdiff
path: root/content/string/suffixArray.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 21:17:29 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 21:17:29 +0100
commit1880ccb6d85c6eb79e724593457877bab431951c (patch)
tree23eddd5bd0b29b3024e170a5ef9023eda9226ab5 /content/string/suffixArray.cpp
parente95f59debd69ee7d45d5c966ce466d23264e1c3c (diff)
get rid of all() and sz()
Diffstat (limited to 'content/string/suffixArray.cpp')
-rw-r--r--content/string/suffixArray.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/content/string/suffixArray.cpp b/content/string/suffixArray.cpp
index 0e301b2..c49bdc9 100644
--- a/content/string/suffixArray.cpp
+++ b/content/string/suffixArray.cpp
@@ -4,19 +4,19 @@ struct SuffixArray {
vector<int> SA, LCP;
vector<vector<int>> P;
- SuffixArray(const string& s) : n(sz(s)), SA(n), LCP(n),
+ SuffixArray(const string& s) : n(ssize(s)), SA(n), LCP(n),
P(__lg(2 * n - 1) + 1, vector<int>(n)) {
- P[0].assign(all(s));
- iota(all(SA), 0);
- sort(all(SA), [&](int a, int b) { return s[a] < s[b]; });
+ P[0].assign(begin(s), end(s));
+ iota(begin(SA), end(SA), 0);
+ ranges::sort(SA, {}, [&](int x) { return s[x]; });
vector<int> x(n);
for (int k = 1, c = 1; c < n; k++, c *= 2) {
- iota(all(x), n - c);
+ iota(begin(x), end(x), n - c);
for (int ptr = c; int i : SA) if (i >= c) x[ptr++] = i - c;
vector<int> cnt(k == 1 ? MAX_CHAR : n);
for (int i : P[k-1]) cnt[i]++;
- partial_sum(all(cnt), begin(cnt));
+ partial_sum(begin(cnt), end(cnt), begin(cnt));
for (int i : x | views::reverse) SA[--cnt[P[k-1][i]]] = i;
auto p = [&](int i) { return i < n ? P[k-1][i] : -1; };
@@ -31,7 +31,7 @@ struct SuffixArray {
int lcp(int x, int y) {
if (x == y) return n - x;
int res = 0;
- for (int i = sz(P) - 1; i >= 0 && max(x, y) + res < n; i--) {
+ for (int i = ssize(P) - 1; i >= 0 && max(x, y) + res < n; i--) {
if (P[i][x + res] == P[i][y + res]) res |= 1 << i;
}
return res;