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