1
0
Fork 0

Update sa.cc

This commit is contained in:
Ariel 2024-01-21 10:07:21 +08:00 committed by GitHub
parent cf752da653
commit 6a5ae7f41d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -35,6 +35,15 @@ void calc_sa() {
}
}
void calc_height() {
for (i = 1, k = 0; i <= n; ++i) {
if (rk[i] == 0) continue;
if (k) --k;
while (s[i + k] == s[sa[rk[i] - 1] + k]) ++k;
height[rk[i]] = k;
}
}
int main() {
untie;
cin >> (s + 1); // array s starts from index 1