Advertisement
trungore10

Untitled

Sep 1st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. void Build_KMP() {
  2. Q.clear();
  3. for (int c = 0; c < 2; ++c) if (Next[0][c] != 0) {
  4. Q.push(Next[0][c]); KMP[Next[0][c]] = 0;
  5. }
  6.  
  7. while (Q.size()) {
  8. int curNode = Q.front(); Q.pop();
  9. for (int c = 0; c < 2; ++c) {
  10. if (!Next[curNode][c]) continue;
  11. isLeaf[Next[curNode][c]] |= isLeaf[curNode];
  12.  
  13. KMP[ Next[curNode][c] ] = Jump(KMP[curNode], c);
  14. Q.push(Next[curNode][c]);
  15.  
  16. Skip[curNode][c] = Jump(curNode, c);
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement