diff options
| author | MZuenni <michi.zuendorf@gmail.com> | 2023-01-11 11:15:50 +0100 |
|---|---|---|
| committer | MZuenni <michi.zuendorf@gmail.com> | 2023-01-11 11:15:50 +0100 |
| commit | 61cac9c0febbb5440b99e22770d917bf3a63c405 (patch) | |
| tree | 98b7dc3b77ada4cffe5b81daded5516b941f28ec /string/suffixAutomaton.cpp | |
| parent | fd1f2b36e95c03625297b7b8cba3b1a04a0cc0ed (diff) | |
dont use .size()
Diffstat (limited to 'string/suffixAutomaton.cpp')
| -rw-r--r-- | string/suffixAutomaton.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/string/suffixAutomaton.cpp b/string/suffixAutomaton.cpp index 15265c8..69aa979 100644 --- a/string/suffixAutomaton.cpp +++ b/string/suffixAutomaton.cpp @@ -1,5 +1,5 @@ constexpr char MIN_CHAR = 'a'; -constexpr long long ALPHABET_SIZE = 26; +constexpr ll ALPHABET_SIZE = 26; struct SuffixAutomaton { struct State { int length, link; @@ -9,8 +9,7 @@ struct SuffixAutomaton { vector<State> states; int size, last; - SuffixAutomaton(string &s) { - states.resize(2 * sz(s)); + SuffixAutomaton(const string &s) : states(2*sz(s)) { size = 1; last = 0; states[0].length = 0; states[0].link = -1; @@ -46,9 +45,9 @@ struct SuffixAutomaton { // Pair with start index and length of LCS. // Index in parameter t. - pair<int, int> longestCommonSubstring(string &t) { + pair<int, int> longestCommonSubstring(const string &t) { int v = 0, l = 0, best = 0, bestpos = 0; - for (int i = 0; i < (int)t.size(); i++) { + for (int i = 0; i < sz(t); i++) { int c = t[i] - MIN_CHAR; while (v && !states[v].next[c]) { v = states[v].link; |
