记录编号 |
332329 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOI 2000]单词查找树 |
最终得分 |
100 |
用户昵称 |
Marvolo |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.017 s |
提交时间 |
2016-10-28 18:33:28 |
内存使用 |
34.92 MiB |
显示代码纯文本
- #include<cstdio>
- #include<cstring>
- using namespace std;
-
- int n,l,len,i;
- char s[110];
- struct Node{
- int son[26];
- }Trie[500010];
-
- inline void Insert(){
- int i=0,p=0;
- for (i=0;i<=l;i++)
- if (Trie[p].son[s[i]-'A']!=0) p=Trie[p].son[s[i]-'A'];
- else p=Trie[p].son[s[i]-'A']=++len;
- }
-
- int main(){
- freopen("trie.in","r",stdin);
- freopen("trie.out","w",stdout);
- while (scanf("%s",&s)!=EOF){
- l=strlen(s)-1;
- Insert();
- }
- printf("%d\n",len+1);
- return 0;
- }