以前看到这道题想到的是SA,做起来不是很美观 学了SAM之后,这题简直是随便搞 ..,'] of longint; s,sa,mx,w,fa:..] of longint; i,n,last,t:longint; ch:char; procedure add(c:char); var p,np,nq,q:longint; begin p:=last; inc(t); np:=t; last:=t; mx[np]:=mx[p]+; w[np]:=; ) ) do begin go[p,c]:=np…