fork(6) download
  1. const int MAXN = 404, MOD = 1e9 + 7, sigma = 26;
  2.  
  3. int term[MAXN], len[MAXN], to[MAXN][sigma], link[MAXN], sz = 1;
  4. void add_str(string s)
  5. {
  6. int cur = 0;
  7. for(auto c: s)
  8. {
  9. if(!to[cur][c - 'a'])
  10. {
  11. to[cur][c - 'a'] = sz++;
  12. len[to[cur][c - 'a']] = len[cur] + 1;
  13. }
  14. cur = to[cur][c - 'a'];
  15. }
  16. term[cur] = cur;
  17. }
  18.  
  19. void push_links()
  20. {
  21. int que[sz];
  22. int st = 0, fi = 1;
  23. que[0] = 0;
  24. while(st < fi)
  25. {
  26. int V = que[st++];
  27. int U = link[V];
  28. if(!term[V]) term[V] = term[U];
  29. for(int c = 0; c < sigma; c++)
  30. if(to[V][c])
  31. {
  32. link[to[V][c]] = V ? to[U][c] : 0;
  33. que[fi++] = to[V][c];
  34. }
  35. else
  36. {
  37. to[V][c] = to[U][c];
  38. }
  39. }
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:14: error: variable or field ‘add_str’ declared void
 void add_str(string s)
              ^
prog.cpp:4:14: error: ‘string’ was not declared in this scope
stdout
Standard output is empty