diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 17:48:10 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 18:01:53 +0100 |
| commit | e55df069a8f83b2c0c2b56c035f49e89516cdaaa (patch) | |
| tree | dd6767e3fc6ac8532661dc75886a3056804d1d46 /content/string | |
| parent | 72bd993483453ed8ebc462f1a33385cd355d486f (diff) | |
minor fixes, let code breathe where possible
Diffstat (limited to 'content/string')
| -rw-r--r-- | content/string/ahoCorasick.cpp | 2 | ||||
| -rw-r--r-- | content/string/rollingHash.cpp | 2 | ||||
| -rw-r--r-- | content/string/rollingHashCf.cpp | 2 | ||||
| -rw-r--r-- | content/string/suffixArray.cpp | 7 | ||||
| -rw-r--r-- | content/string/suffixAutomaton.cpp | 2 | ||||
| -rw-r--r-- | content/string/trie.cpp | 2 |
6 files changed, 9 insertions, 8 deletions
diff --git a/content/string/ahoCorasick.cpp b/content/string/ahoCorasick.cpp index 390d16d..c65e20a 100644 --- a/content/string/ahoCorasick.cpp +++ b/content/string/ahoCorasick.cpp @@ -4,7 +4,7 @@ struct AhoCorasick { int suffix = 0, ch, cnt = 0; array<int, ALPHABET_SIZE> nxt = {}; - vert(int p, int c) : suffix(-p), ch(c) {fill(all(nxt), -1);} + vert(int p, int c): suffix(-p), ch(c) { fill(all(nxt), -1); } }; vector<vert> aho = {{0, -1}}; diff --git a/content/string/rollingHash.cpp b/content/string/rollingHash.cpp index 6e914aa..1157cb7 100644 --- a/content/string/rollingHash.cpp +++ b/content/string/rollingHash.cpp @@ -14,5 +14,5 @@ struct Hash { return (pref[r] - mul(power[r-l], pref[l]) + M) % M; } - static ll mul(__int128 a, ll b) {return a * b % M;} + static ll mul(__int128 a, ll b) { return a * b % M; } }; diff --git a/content/string/rollingHashCf.cpp b/content/string/rollingHashCf.cpp index 84b2e4e..c08a9d3 100644 --- a/content/string/rollingHashCf.cpp +++ b/content/string/rollingHashCf.cpp @@ -13,5 +13,5 @@ struct Hash { return (pref[r] - mul(power[r-l], pref[l]) + M) % M; } - static ll mul(__int128 a, ll b) {return a * b % M;} + static ll mul(__int128 a, ll b) { return a * b % M; } }; diff --git a/content/string/suffixArray.cpp b/content/string/suffixArray.cpp index 8b698d2..0e301b2 100644 --- a/content/string/suffixArray.cpp +++ b/content/string/suffixArray.cpp @@ -8,7 +8,7 @@ struct SuffixArray { P(__lg(2 * n - 1) + 1, vector<int>(n)) { P[0].assign(all(s)); iota(all(SA), 0); - sort(all(SA), [&](int a, int b) {return s[a] < s[b];}); + sort(all(SA), [&](int a, int b) { return s[a] < s[b]; }); vector<int> x(n); for (int k = 1, c = 1; c < n; k++, c *= 2) { iota(all(x), n - c); @@ -19,7 +19,7 @@ struct SuffixArray { partial_sum(all(cnt), begin(cnt)); for (int i : x | views::reverse) SA[--cnt[P[k-1][i]]] = i; - auto p = [&](int i) {return i < n ? P[k-1][i] : -1;}; + auto p = [&](int i) { return i < n ? P[k-1][i] : -1; }; for (int i = 1; i < n; i++) { int a = SA[i-1], b = SA[i]; P[k][b] = P[k][a] + (p(a) != p(b) || p(a+c) != p(b+c)); @@ -27,7 +27,8 @@ struct SuffixArray { for (int i = 1; i < n; i++) LCP[i] = lcp(SA[i-1], SA[i]); } - int lcp(int x, int y) {//x & y are text-indices, not SA-indices + // x & y are text-indices, not SA-indices + int lcp(int x, int y) { if (x == y) return n - x; int res = 0; for (int i = sz(P) - 1; i >= 0 && max(x, y) + res < n; i--) { diff --git a/content/string/suffixAutomaton.cpp b/content/string/suffixAutomaton.cpp index 9a68cb3..d81a05d 100644 --- a/content/string/suffixAutomaton.cpp +++ b/content/string/suffixAutomaton.cpp @@ -4,7 +4,7 @@ struct SuffixAutomaton { struct State { int len, link = -1; array<int, ALPHABET_SIZE> nxt; // map if large Alphabet - State(int l) : len(l) {fill(all(nxt), -1);} + State(int l): len(l) { fill(all(nxt), -1); } }; vector<State> st = {State(0)}; diff --git a/content/string/trie.cpp b/content/string/trie.cpp index 03cf947..d5e092c 100644 --- a/content/string/trie.cpp +++ b/content/string/trie.cpp @@ -3,7 +3,7 @@ constexpr int ALPHABET_SIZE = 2; struct node { int words, ends; array<int, ALPHABET_SIZE> nxt; - node() : words(0), ends(0) {fill(all(nxt), -1);} + node(): words(0), ends(0) { fill(all(nxt), -1); } }; vector<node> trie = {node()}; |
