Skip to content

Commit d6c843b

Browse files
committed
test it compiles with vector
1 parent af2e4b1 commit d6c843b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

library/strings/string_hash.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct str_hash {
2222
ha[i + 1][j] = (ha[i][j] * base + s[i] + 1) % md[j];
2323
}
2424
}
25-
hsh subarray(int l, int r) { // [l, r)
25+
hsh substr(int l, int r) { // [l, r)
2626
hsh res;
2727
rep(j, 0, 2) {
2828
res[j] = ha[r][j] - ha[l][j] * pw[r - l][j] % md[j];

tests/library_checker_aizu_tests/strings/hashing_lib_checker_z_alg.test.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ int main() {
88
cin >> s;
99
int n = sz(s);
1010
str_hash hash(s);
11+
{
12+
vi a(begin(s), end(s));
13+
str_hash hash_vec(a);
14+
assert(hash.substr(0, n) == hash_vec.substr(0, n));
15+
}
1116
for (int i = 0; i < n; i++) {
1217
int start = i, end = n + 1;
1318
while (start + 1 < end) {
1419
int mid = (start + end) / 2;
1520
int len = mid - i;
16-
if (hash.subarray(i, mid) == hash.subarray(0, len))
21+
if (hash.substr(i, mid) == hash.substr(0, len))
1722
start = mid;
1823
else end = mid;
1924
}

0 commit comments

Comments
 (0)