diff --git a/atcoder/string.py b/atcoder/string.py index 07b472a..07f2e72 100644 --- a/atcoder/string.py +++ b/atcoder/string.py @@ -31,13 +31,6 @@ def cmp(x: int, y: int) -> int: def _sa_is(s: typing.List[int], upper: int) -> typing.List[int]: - ''' - SA-IS, linear-time suffix array construction - Reference: - G. Nong, S. Zhang, and W. H. Chan, - Two Efficient Algorithms for Linear Time Suffix Array Construction - ''' - threshold_naive = 10 threshold_doubling = 40 @@ -165,6 +158,14 @@ def induce(lms: typing.List[int]) -> None: def suffix_array(s: typing.Union[str, typing.List[int]], upper: typing.Optional[int] = None) -> typing.List[int]: + ''' + SA-IS, linear-time suffix array construction + + Reference: + G. Nong, S. Zhang, and W. H. Chan, + Two Efficient Algorithms for Linear Time Suffix Array Construction + ''' + if isinstance(s, str): return _sa_is([ord(c) for c in s], 255) elif upper is None: @@ -193,6 +194,8 @@ def cmp(left: int, right: int) -> int: def lcp_array(s: typing.Union[str, typing.List[int]], sa: typing.List[int]) -> typing.List[int]: ''' + Longest-Common-Prefix computation + Reference: T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park, Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its @@ -228,6 +231,8 @@ def lcp_array(s: typing.Union[str, typing.List[int]], def z_algorithm(s: typing.Union[str, typing.List[int]]) -> typing.List[int]: ''' + Z algorithm + Reference: D. Gusfield, Algorithms on Strings, Trees, and Sequences: Computer Science and diff --git a/atcoder/twosat.py b/atcoder/twosat.py index 1f2c1dc..da56b51 100644 --- a/atcoder/twosat.py +++ b/atcoder/twosat.py @@ -5,6 +5,8 @@ class TwoSAT: ''' + 2-SAT + Reference: B. Aspvall, M. Plass, and R. Tarjan, A Linear-Time Algorithm for Testing the Truth of Certain Quantified Boolean