Trie(字典树)
int trie[SIZE][26],tot=1; void insert(char* str) { int len=strlen(str),p=1; for(int k=0; k) { int ch=str[k]-'a'; if(trie[p][ch]==0) trie[p][ch]=++tot; p=trie[p][ch]; } end[p]=true; }
trie数组尽量开大一点,防止越界
int trie[SIZE][26],tot=1; void insert(char* str) { int len=strlen(str),p=1; for(int k=0; k) { int ch=str[k]-'a'; if(trie[p][ch]==0) trie[p][ch]=++tot; p=trie[p][ch]; } end[p]=true; }
trie数组尽量开大一点,防止越界