HDU1671 poj3630 Phone List 字典树
来源:互联网 发布:bigger研究所 知乎 编辑:程序博客网 时间:2024/05/06 11:45
字典树都是套模版的 这是学长跟我说的,有指针型 跟数组型,贴个数组型的 以后 留着看 ,今天 搞懂了
#include<iostream>#include<cstdio>#include<list>#include<algorithm>#include<cstring>#include<string>#include<queue>#include<stack>#include<map>#include<vector>#include<cmath>#include<memory.h>#include<set>#define ll long long#define LL __int64const ll INF=9999999999999;using namespace std;#define M 400000100#define inf 0xfffffff//vector<int> G[10002];//vector<pair<int,int>> ::iterator iter;//map<ll,int>mp;//map<ll,int>::iterator p;int Trie[100002][11];//表示节点数int node[100002];//当前节点的单词数目int value[100002];//当前节点所附带的信息int sizeofTrie; //节点数目void clear()//初始化{memset(Trie[0],0,sizeof(Trie[0]));memset(node,0,sizeof(node));memset(value,0,sizeof(node));sizeofTrie=1;}bool buildTrie(char *s){bool have_build=0;//判断树是否新建了int u=0,len=strlen(s);for(int i=0;i<len;i++){int v=s[i]-'0';if(!Trie[u][v])//节点不存在{memset(Trie[sizeofTrie],0,sizeof(Trie[sizeofTrie]));Trie[u][v]=sizeofTrie++;have_build=1;}if(node[u]==1)return 0;u=Trie[u][v];}if(node[u]==1)return 0;node[u]=1;return have_build;}int main(void){char s[22];int n;int t;cin>>t;while(t--){clear();scanf("%d",&n);bool flag=1;for(int i=0;i<n;i++){scanf("%s",s);if(flag)flag=buildTrie(s);}if(flag)puts("YES");elseputs("NO");}}
- HDU1671 poj3630 Phone List 字典树
- poj3630/hdu1671 Phone List
- HDU1671 POJ3630 Phone List Tire树
- poj3630(Phone List+字典树)
- Phone List(poj3630,字典树)
- POJ3630 Phone List(字典树)
- poj3630 Phone List 字典树
- POJ3630 Phone List(字典树)
- C++——字典树(Trie树)例题——Phone List(POJ3630)(HDU1671)
- 【字典树】 hdu1671 Phone List
- Phone List(hdu1671字典树)
- hdu1671 Phone List (字典树)
- HDU1671 Phone List【字典树】
- HDU1671 Phone List (字典树)
- hdu1671-Phone List 字典树
- ZOJ2876 POJ3630 HDU1671 Phone List,静态Trie树
- POJ3630 Phone List(字典树)
- poj3630—Phone List(字典树)
- 生活感触
- ajax jquery校验用户是否已经注册
- HDU-1025 裸最长递增子序列
- 丑数的处理
- 经典算法之不定方程问题
- HDU1671 poj3630 Phone List 字典树
- word2vec
- 蓝牙4.0设计 CC2540
- Visual Studio 2008高级编程(奋斗的小鸟)_PDF 电子书
- LINUX下的21个特殊符号
- Day04_数据类型占位符使用及进制转换
- 字典树模版
- Java 单例模式及其几种实现代码
- 安卓客户端与服务器端交互(含文件上传、数据传输等)