From dc44be31c5f715d2aecbf5bc1a164525397b9511 Mon Sep 17 00:00:00 2001 From: Tommy Chiang Date: Sun, 11 Feb 2024 02:38:11 +0800 Subject: [PATCH] Fix SA LCP --- codes/String/SuffixArrayTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/String/SuffixArrayTools.cpp b/codes/String/SuffixArrayTools.cpp index 5fd1a73a..3c3e8946 100644 --- a/codes/String/SuffixArrayTools.cpp +++ b/codes/String/SuffixArrayTools.cpp @@ -26,7 +26,7 @@ template struct SparseTableSA : Suffix { } int lcp(int a, int b) { if (a == b) return n - a; - a = rev[a]; b = rev[b]; + a = rev[a] + 1, b = rev[b] + 1; if (a > b) swap(a, b); const int lg = __lg(b - a); return min(mn[lg][a], mn[lg][b - (1 << lg)]);