上海大学 ACM 模板 by kuangbin
next[0]=m;
int j=0;
while(j+1
上海大学 ACM 模板 by kuangbin
Mp[i]=mx>i?min(Mp[2*id-i],mx-i):1;
while(Ma[i+Mp[i]]==Ma[i-Mp[i]])Mp[i]++;
if(i+Mp[i]>mx)
{
mx=i+Mp[i];
id=i;
}
Ma[l++]=s[i];
Ma[l++]='#';
Ma[l++]='#';
for(int i=0;i
#include
#include
#include
#include
using namespace std;
struct Trie
{
int next[500010][26],fail[500010],end[500010];
7 / 173
ACM 模板
kuangbin
上海大学 ACM 模板 by kuangbin
int len = strlen(buf);
int now = root;
for(int i = 0;i < len;i++)
{
}
end[now]++;
if(next[now][buf[i]-'a'] == -1)
now = next[now][buf[i]-'a'];
next[now][buf[i]-'a'] = newnode();
next[L][i] = -1;
for(int i = 0;i < 26;i++)
end[L++] = 0;
return L-1;
int root,L;
int newnode()
{
}
void init()
{
L = 0;
root = newnode();
}
void insert(char buf[])
{
}
void build()
{
}
int query(char buf[])
{
queueQ;
fail[root] = root;
for(int i = 0;i < 26;i++)
while( !Q.empty() )
{
}
int len = strlen(buf);
int now = root;
int res = 0;
for(int i = 0;i < len;i++)
{
int now = Q.front();
Q.pop();
for(int i = 0;i < 26;i++)
if(next[now][i] == -1)
else
{
}
next[root][i] = root;
if(next[root][i] == -1)
else
{
}
fail[next[root][i]] = root;
Q.push(next[root][i]);
next[now][i] = next[fail[now]][i];
fail[next[now][i]]=next[fail[now]][i];
Q.push(next[now][i]);
8 / 173
ACM 模板
kuangbin