diff options
| -rw-r--r-- | other/stress.sh | 2 | ||||
| -rw-r--r-- | string/z.cpp | 16 | ||||
| -rw-r--r-- | tcr.pdf | bin | 666406 -> 667072 bytes |
3 files changed, 9 insertions, 9 deletions
diff --git a/other/stress.sh b/other/stress.sh index 39424ce..d264c2a 100644 --- a/other/stress.sh +++ b/other/stress.sh @@ -2,6 +2,6 @@ for i in {1..1000}; do printf "\r$i" python3 gen.py > input # generate test with gen.py ./a.out < input > out # execute ./a.out - ./b.out < input > out2 # execute ./b.out + ./b.out < input > out2 # execute ./b.out diff out out2 || break done diff --git a/string/z.cpp b/string/z.cpp index c128e9d..069fa38 100644 --- a/string/z.cpp +++ b/string/z.cpp @@ -1,10 +1,10 @@ vector<int> Z(const string& s) { - int n = sz(s); - vector<int> z(n); - for (int i = 1, x = 0; i < n; i++) { - z[i] = max(0, min(z[i - x], x + z[x] - i)); - while (i + z[i] < n && s[z[i]] == s[i + z[i]]) { - x = i, z[i]++; - }} - return z; + int n = sz(s); + vector<int> z(n); + for (int i = 1, x = 0; i < n; i++) { + z[i] = max(0, min(z[i - x], x + z[x] - i)); + while (i + z[i] < n && s[z[i]] == s[i + z[i]]) { + x = i, z[i]++; + }} + return z; } Binary files differ |
