1 //
2 // trie树模板.cpp
3 // 7.24集训
4 //
5 // Created by skygao on 2019/7/24.
6 // Copyright © 2019 skygao. All rights reserved.
7 //
8
9 #include <stdio.h>
10 #include <cstdlib>
11 #include <string>
12 #include <cstring>
13 #include <iostream>
14 #include <algorithm>
15 #define maxn 10005
16 #define maxm 100005
17 #define re register
18 using namespace std;
19 const int sz=26;//字符集的大小(26个小写字母)
20 char st[maxn];//待插入的字符串
21 struct Node
22 {
23 int ch[sz];
24 int flag;//当前节点是不是一个字符串的结尾
25 }a[maxm];
26 int root=0,node_num=0;
27 void insert(int x,int i,int l)//l待插入字符串st的长度
28 {
29 if(i==l)
30 {
31 a[x].flag=true;
32 return ;
33 }
34 int c=st[i]-'a';
35 if(!a[x].ch[c])
36 a[x].ch[c]=++node_num;
37 insert(a[x].ch[c],i+1,l);
38 }
39 int main()
40 {
41
42 return 0;
43 }