#include
#include
struct
node
}*q[1000010];
char
ss[1010],s[55];
void
insert(
char
s,node *root)
p->num++;
}
void
acmove(node *root)
p=p->fail;
}
if
(p==null)
now->next[i]->fail=root;
}
q[tail++]=now->next[i];
}
}
}
}
int
find(node *root)
i++;
}
return
numb;
}
int
main()
acmove(root);
scanf
(
"%s"
,ss);
int
w=find(root);
printf
(
"%dn"
,w);
}
return
0;
}
hdu 2222 AC 自動機 模版(陣列實現)
ac 自動機 模版 原文匹配查詢時講錯了,其他都挺好 原文博主知錯懶得改 t個樣例,n個單詞,乙個文字串,求文字串中單詞出現的次數。若給出單詞ab,ab 文字ab,匹配數為2 若給出 n個不重複的單詞和乙個文字,問單詞的出現次數,則cntword j 不置 1,且迴圈條件變為 j 0。如單詞aa b...
hdu 2222 ac自動機模板
題意 題意 給出n個串,然後給一篇文章,問這n個串有多少個在文章裡面出現過。trick n個串可能有相同的,需按照不同串處理。剛學ac自動機,沒學明白,這 也是照著別人部落格寫的,弱爆 include include include include include using namespace s...
hdu2222 (AC自動機模板)
題 學習出 主要是fail的建立。在跳的過程就是不斷跳fail,而不是跳到乙個fail再往下!include include include include include using namespace std typedef long long ll const int m 2e6 6 int ...