KeyWords Search(AC automation)
摘要:#include <cstdio>
#include <cstring>
using namespace std; const int num_char=26;
struct TrieNode
{ TrieNode *branch[num_char]; TrieNode *fail; int count;//if this is the last node of the word TrieNode() { fail=NULL; count=0; memset(branch,NULL,sizeof(bra...
阅读全文
posted @
2012-10-24 18:44
MicZ
阅读(197)
推荐(0)
HOJ 1898 Babelfish(Trie树)
摘要:题意就是先输入一个字典: 目标字符串-----输入字符串然后输入一个字符串,在上面的对应关系中进行查找,如果有则输出目标字符串,没有则输出eh。如果不想超时的话,明显就要套字典树了。代码贴上来,留作模板。字典树还是挺简单易懂的嘛。。。#include <iostream>
#include <cstdio>
#include <cstring>
#include <memory.h> using namespace std; const int num_char=26; struct TrieNode
{ TrieNode* branch[num
阅读全文
posted @
2012-08-27 22:26
MicZ
阅读(117)
推荐(0)