码迷,mamicode.com
首页 > 其他好文 > 详细

222

时间:2018-02-05 20:02:54      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:for   cst   bcd   int   char s   const   post   pos   while   

#include <cstdio>
#include <algorithm>
using namespace std;
const int N=12000;
int son[N][26], q[N], end[N], ans[N], n;
char s[1000007];

int main()
{
while(scanf("%d",&n) && n)
{
int rt=newp=1;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
int cur=rt,m=strlen(s+1);
for(int j=1;j<=m;j++)
{
if(!son[cur][s[j]-‘a‘]) son[cur][s[j]-‘a‘]=++newp;
cur=son[cur][s[j]-‘a‘];
}
end[i]=cur;
}
// abcdefg
}
}

222

标签:for   cst   bcd   int   char s   const   post   pos   while   

原文地址:https://www.cnblogs.com/noblex/p/8418976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!