fork(7) download
  1. const int MAXN = 1e6 + 42;
  2.  
  3. map<char, int> to[MAXN];
  4. int link[MAXN], que[MAXN], sz = 1;
  5.  
  6. void add_str(string s, int k)
  7. {
  8. int v = 0;
  9. for(auto c: s)
  10. {
  11. if(!to[v][c]) to[v][c] = sz++;
  12. v = to[v][c];
  13. }
  14. }
  15.  
  16. void push_links()
  17. {
  18. link[0] = -1;
  19. int st = 0, fi = 1;
  20. que[0] = 0;
  21. while(st < fi)
  22. {
  23. int v = que[st++];
  24. for(auto it: to[v])
  25. {
  26. int u = it.second;
  27. int c = it.first;
  28. int j = link[v];
  29. while(j != -1 && !to[j][c]) j = link[j];
  30. if(j != -1) link[u] = to[j][c];
  31. que[fi++] = u;
  32. }
  33. }
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:1: error: ‘map’ does not name a type
 map<char, int> to[MAXN];
 ^
prog.cpp:6:14: error: variable or field ‘add_str’ declared void
 void add_str(string s, int k)
              ^
prog.cpp:6:14: error: ‘string’ was not declared in this scope
prog.cpp:6:24: error: expected primary-expression before ‘int’
 void add_str(string s, int k)
                        ^
stdout
Standard output is empty