| 11 | aho_corasick(vector<string> keywords) { |
| 12 | go = new go_node(); |
| 13 | iter(k, keywords) { |
| 14 | go_node *cur = go; |
| 15 | iter(c, *k) |
| 16 | cur = cur->next.find(*c) != cur->next.end() ? |
| 17 | cur->next[*c] : (cur->next[*c] = new go_node()); |
| 18 | cur->out = new out_node(*k, cur->out); } |
| 19 | queue<go_node*> q; |
| 20 | iter(a, go->next) q.push(a->second); |
| 21 | while (!q.empty()) { |