We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 97d50cf commit 2ddf97eCopy full SHA for 2ddf97e
library/strings/suffix_array/suffix_array_short.hpp
@@ -11,13 +11,18 @@
11
//! @time O(n * log^2(n))
12
//! @space O(n)
13
auto sa_short(const auto& s) {
14
+ const int K = 4;
15
int n = sz(s);
16
vi sa(n), sa_inv(all(s)), lcp(n - 1);
17
iota(all(sa), 0);
- for (int k = 1; k <= n; k *= 2) {
18
+ for (int j = 1; j <= n; j *= K) {
19
vi x(sa_inv);
20
auto proj = [&](int i) {
- return pair(x[i], i + k < n ? x[i + k] : -1);
21
+ array<int, K> res;
22
+ rep (k, 0, K)
23
+ res[k] = i + j * k < n ? x[i + j * k] : -1;
24
+ return res;
25
+ //return pair(x[i], i + j < n ? x[i + j] : -1);
26
};
27
ranges::sort(sa, {}, proj);
28
sa_inv[sa[0]] = 0;
0 commit comments