2011年3月15日

poj 3581

摘要: 十分易错的题,后缀数组与最小表示都可行,我用后缀数组做。注意: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 阅读全文

posted @ 2011-03-15 15:20 宇宙吾心 阅读(311) 评论(0) 推荐(0)

poj 3691

摘要: ac自动机+dp#include<iostream>#include<fstream>using namespace std;struct e{ int p[5]; int end;}trie[1001];int n,m,K;int hash[300];int state=1;int f[1001];void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]==0) trie[i].p[hash[c[j]]]=++state; i=trie[i].p[hash[c[j]]]; j++; 阅读全文

posted @ 2011-03-15 13:54 宇宙吾心 阅读(669) 评论(0) 推荐(0)

poj 3294

摘要: 后缀数组,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+ 阅读全文

posted @ 2011-03-15 10:43 宇宙吾心 阅读(412) 评论(0) 推荐(0)

导航