摘要:十分易错的题,后缀数组与最小表示都可行,我用后缀数组做。注意:1. 必须可分成三段。2. 后缀数组最后一个字符应定义成最大数。3.求第二段与第三段的划分时,数组应扩成两倍,再求后缀数组。易错例子:85 0 3 1 2 3 1 4错误程序输出:05134132正确的应该是:05132134代码:#include<iostream>#include<fstream>using namespace std;#define N 400010int sa[N],sa1[N],rank[N],rank1[N],c[N],h[N];int m[N];int n,pow,count;i
阅读全文
摘要:后缀数组,height的考察。代码:#include<iostream>#include<fstream>using namespace std;#define N 100200int sa[N],sa1[N],rank[N],rank1[N],c[N],h[N];int m[N];int n,pow,count;int cmp(const void *a,const void *b){ int x=*(int*)a; int y=*(int*)b; if(rank[x]!=rank[y]) return(1); else if(rank[x+pow]!=rank[y+
阅读全文
摘要:后缀数组,height的二分。#include<iostream>#include<fstream>using namespace std;#define N 20011int sa[N],sa1[N],rank[N],rank1[N],c[N],h[N];int m[N];int n,pow,count;int cmp(const void *a,const void *b){ int x=*(int*)a; int y=*(int*)b; if(rank[x]!=rank[y]) return(1); else if(rank[x+pow]!=rank[y+pow]
阅读全文
摘要:后缀数组,二分求多串子串,height数组山的结构。#include<iostream>#include<fstream>using namespace std;#define N 620int sa[N],sa1[N],rank[N],rank1[N],c[N],h[N];char m[N];int n,pow,count;int cmp(const void *a,const void *b){ int x=*(int*)a; int y=*(int*)b; if(rank[x]!=rank[y]) return(1); else if(rank[x+pow]!=r
阅读全文
摘要:后缀数组,经典,height数组的深入理解,想象一下山的形状就明白了。代码:#include<iostream>#include<fstream>using namespace std;#define N 20003int sa[N],sa1[N],rank[N],rank1[N],c[N],h[N],m[N];int n,pow;int cmp(const void *a,const void *b){ int x=*(int*)a; int y=*(int*)b; if(rank[x]!=rank[y]) return(1); else if(rank[x+pow]
阅读全文
摘要:后缀数组代码:#include<iostream>#include<fstream>using namespace std;int sa[200003],sa1[200003],rank1[200003];int rank[200003],y[200003],h[200003];int pow=1;char m[200004];int c[200003];int cmp2(const void *a,const void *b){ int x=*(int*)a; int y=*(int*)b; if(rank[x]!=rank[y]) return(rank[x]-ra
阅读全文