algo — C++23 日本語リファレンス GitHub

string_suffix_automaton

クラス · Suffix Automaton

template <int ALPHABET_SIZE = 26, char BASE = 'a'>
struct string_suffix_automaton;

概要

固定alphabet向けSuffix Automaton

計算量

構築・破棄

名前 説明 計算量
(constructor) (1) 初期状態だけを持つautomatonを構築する
(2) 列sからautomatonを構築する
(1) $O(ALPHABET_SIZE)$
(2) $O(n\cdot ALPHABET_SIZE)$

メンバ関数

名前 説明 計算量
extend 末尾に文字cを追加する 償却 $O(ALPHABET_SIZE)$
next_state 現在の照合状態へ文字cを追加した状態と一致長を返す 単発最悪 $O(n)$、文字列を順に処理する場合は償却 $O(1)$
size 状態数を返す $O(1)$

メンバ型

名前 説明 計算量
node 固定alphabet automatonの1状態 構築は $O(ALPHABET_SIZE)$

メンバ変数

名前 説明 計算量
nodes 全状態 参照は $O(1)$
last 文字列全体に対応する末尾状態 参照は $O(1)$

メンバの詳細

(constructor)

// (1)
string_suffix_automaton();

// (2)
template <class Container>
explicit string_suffix_automaton(const Container &s);

(1) 初期状態だけを持つautomatonを構築する

(2) 列sからautomatonを構築する

node

struct node;

固定alphabet automatonの1状態

メンバ 説明
len この状態が表す最長文字列の長さ
link suffix link先の状態ID
next 文字ごとの遷移先
node 長さとsuffix linkから状態を構築する

関連項目