Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Build_KMP() {
- Q.clear();
- for (int c = 0; c < 2; ++c) if (Next[0][c] != 0) {
- Q.push(Next[0][c]); KMP[Next[0][c]] = 0;
- }
- while (Q.size()) {
- int curNode = Q.front(); Q.pop();
- for (int c = 0; c < 2; ++c) {
- if (!Next[curNode][c]) continue;
- isLeaf[Next[curNode][c]] |= isLeaf[curNode];
- KMP[ Next[curNode][c] ] = Jump(KMP[curNode], c);
- Q.push(Next[curNode][c]);
- Skip[curNode][c] = Jump(curNode, c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement