diff options
author | Ta180m | 2019-09-16 22:08:45 -0500 |
---|---|---|
committer | Ta180m | 2019-09-16 22:08:45 -0500 |
commit | a4913b1056bdcb010a2fddea167f8a3ce6d7b956 (patch) | |
tree | deb18333d473cb2343398f06944276ed9a40a6b5 /String | |
parent | 2c3db2a92acee49f2d353ae838ccdd9ad1587e42 (diff) | |
parent | da9eaf2b19e9fbf5d180fed0057969e2dd525056 (diff) |
Merge branch 'master' of https://github.com/Ta180m/Library
Diffstat (limited to 'String')
-rw-r--r-- | String/suffix_array.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/String/suffix_array.cpp b/String/suffix_array.cpp index 434e6ba..7a989d2 100644 --- a/String/suffix_array.cpp +++ b/String/suffix_array.cpp @@ -1,8 +1,3 @@ -#include <algorithm> -#include <vector> -#include <string> -using namespace std; - vector<int> suffix_array(string& S) { int N = S.length(); vector<int> SA(N), rank(N); @@ -21,8 +16,7 @@ vector<int> suffix_array(string& S) { vector<int> cnt(N); for (int i = 0; i < N; i++) cnt[i] = i; for (int i = 0; i < N; i++) { - int s = tmp[i] - t; - if (s >= 0) SA[cnt[rank[s]]++] = s; + if (tmp[i] >= t) SA[cnt[rank[tmp[i] - t]]++] = tmp[i] - t; } } return SA; |