hdu 3460 Ancient Printer trie字典树
来源:互联网 发布:隔音玻璃效果好吗 知乎 编辑:程序博客网 时间:2024/05/16 14:19
#include<bits/stdc++.h>using namespace std;int ans;struct trie{ int num; trie *next[26];};trie *rt=new trie;void settrie(char *s){ trie *p=rt,*t; int n=strlen(s),i,c; if(n>p->num) p->num=n; for(i=0; i<n; i++) { c=s[i]-'a'; if(p->next[c]==NULL) { ans+=2; t=new trie; for(int j=0; j<26; j++) { t->next[j]=NULL; } p->next[c]=t; } p=p->next[c]; }}int main(){ int n,i; char s[100]; while(~scanf("%d",&n)) { rt->num=0; for(i=0; i<26; i++) { rt->next[i]=NULL; } ans=0; for(i=0; i<n; i++) { scanf("%s",s); settrie(s); ans++; } ans=ans-rt->num; printf("%d\n",ans); } return 0;}
0 0
- hdu 3460 Ancient Printer trie字典树
- 【trie】hdu 3460 Ancient Printer
- Ancient Printer 字典树 hdu 3460
- 【字典树】hdu 3460 Ancient Printer
- hdu 3460 Ancient Printer (字典树)
- hdu 3460 Ancient Printer 字典树
- HDU - 3460 Ancient Printer(字典树)
- HDU 3460 Ancient Printer (字典树)
- HDU 3460 Ancient Printer(字典树)
- hdu 3460-Ancient Printer(字典树&&贪心)
- hdu 字典树Ancient Printer
- hdu 3460 Ancient Printer(贪心 or Trie树)
- hdu 3460 Ancient Printer(trie tree)
- HDU 3460 Ancient Printer(思维题或字典树)
- hdu-3460-Ancient Printer(贪心+字典树)
- HDOJ-3460Ancient Printer(Trie)
- Trie树 hdu3460 Ancient Printer
- hdu 3460 Ancient Printer
- CF#306-C - Divisibility by Eight-数学+暴力
- 收起键盘的四种方法
- 继承
- 类
- 重载
- hdu 3460 Ancient Printer trie字典树
- 新手学python--字典
- C#中泛型集合List<T>反序列化问题及解决方法
- LT8619B,HDMI转RGB,HDMI转LVDS,MHL转RGB,MHL转LVDS
- 对待生命
- 程序中的除法取余
- [C]日志函数
- 隐式类型
- ocp-189