【*】后缀数组(dc3算法构造)

const int Max = 200001;
int num[Max];
int r[Max * 3], sa[Max * 3];
int rank[Max], height[Max];
int wa[Max], wb[Max], wv[Max], wd[Max];
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x) * 3 + 1 : ((x) - tb) * 3 + 2)
int c0(int *r, int a, int b)
{ return r[a] == r[b] && r[a + 1] == r[b + 1] && r[a + 2] == r[b + 2]; }
int c12(int k, int *r, int a, int b)
{ if (k == 2) return r[a] < r[b] || r[a] == r[b] && c12(1, r, a + 1, b + 1);
 else return r[a]=0;i--) b[--wd[wv[i]]]=a[i];
     return;
}
void dc3(int *r,int *sa,int n,int m)
{
     int i,j,*rn=r+n,*san=sa+n,ta=0,tb=(n+1)/3,tbc=0,p;
     r[n]=r[n+1]=0;
     for(i=0;i

你可能感兴趣的:(数据结构)