This documentation is automatically generated by online-judge-tools/verification-helper
z_algorithm(s: Sequence[Any]) -> List[int]
s
と s[i:]
の共通接頭辞の長さを格納した長さ n = len(s)
の配列を返す。計算量 $O(n)$
def z_algorithm(s):
res = [0] * len(s)
res[0] = len(s)
i, j = 1, 0
while i < len(s):
while i + j < len(s) and s[j] == s[i + j]:
j += 1
res[i] = j
if j == 0:
i += 1
continue
k = 1
while i + k < len(s) and k + res[k] < j:
res[i + k] = res[k]
k += 1
i, j = i + k, j - k
return res
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
raise NotImplementedError
NotImplementedError