Trie struct node int next26 int fail int Slides: 22 Download presentation Trie� 代��� struct node { int next[26]; int fail; int count; void init() { memset(next, -1, sizeof(next)); fail = 0; count = 0; } }s[500005]; void make_fail() { qin = qout = 0; int i, ind_f; for(i = 0; i < 26; i++) { if(s[0]. next[i] != -1) { q[qin++] = s[0]. next[i]; } } while(qin != qout) { ind = q[qout++]; for(i = 0; i < 26; i++) { //找之后的子�点 if(s[ind]. next[i] != -1) { q[qin++] = s[ind]. next[i]; ind_f = s[ind]. fail; while(ind_f > 0 && s[ind_f]. next[i] == -1) ind_f = s[ind_f]. fail; if(s[ind_f]. next[i] != -1) ind_f = s[ind_f]. next[i]; s[s[ind]. next[i]]. fail = ind_f; //子�点的 fail根据父�点 fail指�的搞定 } } } �目 Poj 1204 4052(�目在 4044上下�) Hdu 2222 3065 Struct node int data struct node* nextTypedef struct in cTypedef struct tree int infoTypedef struct treeTypedef struct treeStruct node int i float jWhat are structureTypedef struct node int valueStruct node int dataSum0How to copy a struct in cStruct node *nextTypedef struct nodeTypedef struct tree int infoTypedef listStruct node *Public int divide(int a int b)Int max(int x int y)Interface calculator public int add class testPublic void drawsquare(int x, int y, int len)Hamiltonian operatorReference node and non reference nodeReference node and non reference node