int trie[SIZE][26],tot=1;
void insert(char* str) {
    int len=strlen(str),p=1;
    for(int k=0; k<len; k++) {
        int ch=str[k]-'a';
        if(trie[p][ch]==0) trie[p][ch]=++tot;
        p=trie[p][ch];
    }
    end[p]=true;
}

trie数组尽量开大一点,防止越界

posted on 2022-03-12 11:19  我疯故我在  阅读(38)  评论(0)    收藏  举报