原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1305
字典树裸题,如下:
1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 const int Max_N = 100000; 7 struct Node{ 8 int cnt; 9 Node *next[2]; 10 inline void set(){ 11 cnt = 0; 12 for (int i = 0; i < 2; i++) next[i] = NULL; 13 } 14 }; 15 struct Trie{ 16 Node stack[Max_N], *root, *tail; 17 void init(){ 18 tail = &stack[0]; 19 root = tail++; 20 root->set(); 21 } 22 inline Node *newNode(){ 23 Node *p = tail++; 24 p->set(); 25 return p; 26 } 27 inline void insert(Node *x, char *src){ 28 char *p = src; 29 while (*p != '