记录编号 |
415668 |
评测结果 |
AAAAAAAAAA |
题目名称 |
词链 |
最终得分 |
100 |
用户昵称 |
Hzoi_QTY |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2017-06-18 16:38:45 |
内存使用 |
0.00 MiB |
显示代码纯文本
- #include<iostream>
- #include<cstring>
- #include<cstdlib>
- #include<cstdio>
- using namespace std;
- int f[50001],n,t,sz;
- struct trie
- {
- int dfn;
- trie *ch[28];
- } node[50001],*root;
- inline trie* newnode()
- {
- sz++;
- return &node[sz];
- }
- inline void insert(char *s)
- {
- int len=strlen(s);
- trie *now=root;
- ++t;
- for(int i=0;i<len;i++)
- {
- if(now->ch[s[i]-'a']==NULL)
- now->ch[s[i]-'a']=newnode();
- if(now->dfn)
- f[t]=max(f[now->dfn],f[t]);
- now=now->ch[s[i]-'a'];
- }
- now->dfn=t;
- f[t]++;
- }
- int yjn()
- {
- freopen("link.in","r",stdin);
- freopen("link.out","w",stdout);
- scanf("%d",&n);
- root=newnode();
- while(n--)
- {
- char a[60];
- scanf("%s",a);
- insert(a);
- }
- int s=0;
- for(int i=1;i<=t;i++)
- s=max(f[i],s);
- cout<<s;
- //while(1);
- }
- int qty=yjn();
- int main()
- {
- ;
- }