void extend(int c)
{
int cur=++sz,p=last;
d[cur]=1;
st[cur].len=st[last].len+1;
while(p!=-1 && !st[p].nex[c])
st[p].nex[c]=cur,p=st[p].link;
if(p==-1) st[cur].link=0;
else
{
int q=st[p].nex[c];
if(st[p].len+1==st[q].len) st[cur].link=q;
else
{
int cl=++sz;
st[cl].len=st[p].len+1,st[cl].link=st[q].link;
memcpy(st[cl].nex,st[q].nex,sizeof(st[q].nex));
while(p!=-1 && st[p].nex[c]==q)
st[p].nex[c]=cl,p=st[p].link;
st[q].link=st[cur].link=cl;
}
}
last=cur;
}
为什么这道题在 extend 函数中需要给 cur 节点的 size 赋成1?