Skip to content

Commit 58f324e

Browse files
authored
Merge pull request #58 from masa-aa/patch-3
Update string.py
2 parents 8e61383 + 1d3e444 commit 58f324e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

atcoder/string.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import copy
21
import functools
32
import typing
43

@@ -11,7 +10,7 @@ def _sa_naive(s: typing.List[int]) -> typing.List[int]:
1110
def _sa_doubling(s: typing.List[int]) -> typing.List[int]:
1211
n = len(s)
1312
sa = list(range(n))
14-
rnk = copy.deepcopy(s)
13+
rnk = s.copy()
1514
tmp = [0] * n
1615
k = 1
1716
while k < n:
@@ -75,14 +74,14 @@ def induce(lms: typing.List[int]) -> None:
7574
nonlocal sa
7675
sa = [-1] * n
7776

78-
buf = copy.deepcopy(sum_s)
77+
buf = sum_s.copy()
7978
for d in lms:
8079
if d == n:
8180
continue
8281
sa[buf[s[d]]] = d
8382
buf[s[d]] += 1
8483

85-
buf = copy.deepcopy(sum_l)
84+
buf = sum_l.copy()
8685
sa[buf[s[n - 1]]] = n - 1
8786
buf[s[n - 1]] += 1
8887
for i in range(n):
@@ -91,7 +90,7 @@ def induce(lms: typing.List[int]) -> None:
9190
sa[buf[s[v - 1]]] = v - 1
9291
buf[s[v - 1]] += 1
9392

94-
buf = copy.deepcopy(sum_l)
93+
buf = sum_l.copy()
9594
for i in range(n - 1, -1, -1):
9695
v = sa[i]
9796
if v >= 1 and ls[v - 1]:
@@ -160,7 +159,6 @@ def suffix_array(s: typing.Union[str, typing.List[int]],
160159
upper: typing.Optional[int] = None) -> typing.List[int]:
161160
'''
162161
SA-IS, linear-time suffix array construction
163-
164162
Reference:
165163
G. Nong, S. Zhang, and W. H. Chan,
166164
Two Efficient Algorithms for Linear Time Suffix Array Construction
@@ -195,7 +193,6 @@ def lcp_array(s: typing.Union[str, typing.List[int]],
195193
sa: typing.List[int]) -> typing.List[int]:
196194
'''
197195
Longest-Common-Prefix computation
198-
199196
Reference:
200197
T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park,
201198
Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its
@@ -232,7 +229,6 @@ def lcp_array(s: typing.Union[str, typing.List[int]],
232229
def z_algorithm(s: typing.Union[str, typing.List[int]]) -> typing.List[int]:
233230
'''
234231
Z algorithm
235-
236232
Reference:
237233
D. Gusfield,
238234
Algorithms on Strings, Trees, and Sequences: Computer Science and

0 commit comments

Comments
 (0)