我想摆脱这个(int P[MAXLG][MAXN]
)全局变量,有人知道该怎么做吗?
int P[MAXLG][MAXN];
int BuildSuffix(char A[MAXN]){
int N,i,stp,cnt;
for (N = strlen(A), i = 0; i < N; i ++)
P[0][i] = A[i] - 'a';
for (stp = 1, cnt = 1; cnt >> 1 < N; stp ++, cnt <<= 1)
{
for (i = 0; i < N; i ++)
{
L[i].nr[0] = P[stp - 1][i];
L[i].nr[1] = i + cnt < N ? P[stp - 1][i + cnt] : -1;
L[i].p = i;
}
sort(L,L+N,cmp);
for (i = 0; i < N; i ++)
P[stp][L[i].p] = i > 0 && L[i].nr[0] == L[i - 1].nr[0] && L[i].nr[1] ==
L[i - 1].nr[1] ? P[stp][L[i - 1].p] : i;
}
}