Morass

trie

Apr 17th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. int t[26][MX],L,E[MX];
  2. void addW(char *c,int l){
  3.     if(!L){F(26)t[i][0]=-1;L=1;*E=-1;}
  4.     int nd(0);
  5.     for(int i(0);i<l;++i)
  6.         if(~t[c[i]-'a'][nd])
  7.             nd=t[c[i]-'a'][nd];
  8.         else{
  9.             t[c[i]-'a'][nd]=L,E[nd=L++]=-1;
  10.             F(26)t[i][nd]=-1;
  11.         }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment