188
правок
Изменения
→Реализация
p = last
'''while''' p >= 0 '''and''' edges[p].find(c) == ''null''''':'''
edges[p][c] = cur
p = link[p]
'''if''' p != -1''':'''
q = edges[p][c]
'''if''' len[p] + 1 == len[q]''':'''
link[cur] = q
'''else:'''
new = clone(q) <font color="green">// скопируем состояние <tex>q</tex></font>
len[new] = len[p] + 1
link[q] = link[cur] = new
'''while''' p >= 0 '''and''' edges[p][c] == q''':'''
edges[p][c] = new
p = link[p]