设为首页 加入收藏

TOP

Codeforces 235C. Cyclical Quest 后缀自动机(二)
2015-11-21 00:59:18 来源: 作者: 【 】 浏览:6
Tags:Codeforces 235C. Cyclical Quest 后缀 动机
r[maxn]; int tn; int vis[maxn]; int READ_STR(char *str) { int i=0; char ch; while(true) { ch=getchar(); if(ch=='\n') break; str[i++]=ch; } str[i]=0; return i; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int len=READ_STR(stmain); SAM_init(); for(int i=0;i fa->len) cur=cur->fa; } int id=i; if(id>=n) id-=n; int to = str[id]-'a'; while(cur!=0&&cur->next[to]==0) { cur=cur->fa; if(cur!=0) nowlen=cur->len; } if(cur!=0&&cur->next[to]!=0) { cur=cur->next[to]; nowlen++; } else { cur=SAM_root; nowlen=0; } if(nowlen==n) { if(vis[cur->id]!=cas) { vis[cur->id]=cas; ans+=num[cur->id]; } } } printf("%d\n",ans); } return 0; }

?

?

?

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇leetcode 2 Add two numbers 下一篇hdu 1535 Invitation Cards

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: