We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9f834a9 commit 76cc0f9Copy full SHA for 76cc0f9
library/strings/suffix_array/suffix_array_short.hpp
@@ -27,10 +27,10 @@ auto sa_short(const auto& s) {
27
rep(i, 0, n - 1) {
28
sa_inv[sa[i + 1]] = sa_inv[sa[i]];
29
if (f(sa[i + 1]) != f(sa[i])) {
30
- sa_inv[sa[i]]++;
+ sa_inv[sa[i + 1]]++;
31
rep (k, 0, K) {
32
if (f(sa[i + 1])[k] != f(sa[i])[k]) {
33
- lcp[i] = j * k + (i + j * k < n ? y[i + j * k] : 0);
+ lcp[i] = j * k + (sa[i] + j * k < n ? y[sa_inv[sa[i] + j * k]] : 0);
34
}
35
36
} else {
0 commit comments