From 6a5ae7f41d095e46f5817cf878b1b77e0dec95f4 Mon Sep 17 00:00:00 2001 From: Ariel Date: Sun, 21 Jan 2024 10:07:21 +0800 Subject: [PATCH] Update sa.cc --- string/sa.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/string/sa.cc b/string/sa.cc index 0fee3aa..ee477b0 100644 --- a/string/sa.cc +++ b/string/sa.cc @@ -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