测试点5、6、7、8、9、10都是WA,
测试点5的数据输进去卡住,猜想数组开小了
但是加大到字符串数量*字符串常度还是不行
#include <bits/stdc++.h>
using namespace std;
int ne[500005][30];
bool over1[500005];
int nee[5000005][30];
bool over2[5000005];
char s[55];
void insert()
{
int root=0;
int cnt=0;
int ch;
for(int i=0;i<strlen(s);i++)
{
ch=s[i]-'a';
if(ne[root][ch]==0)
ne[root][ch]=++cnt;
root=ne[root][ch];
}
over1[root]=1;
}
void insert2()
{
int root=0;
int cnt=0;
int ch;
for(int i=0;i<strlen(s);i++)
{
ch=s[i]-'a';
if(nee[root][ch]==0)
nee[root][ch]=++cnt;
root=nee[root][ch];
}
over2[root]=1;
}
bool check1()
{
int root=0;
int cnt=0;
int ch;
for(int i=0;i<strlen(s);i++)
{
ch=s[i]-'a';
if(!ne[root][ch])
return false;
root=ne[root][ch];
}
return over1[root];
}
bool check2()
{
int root=0;
int cnt=0;
int ch;
for(int i=0;i<strlen(s);i++)
{
ch=s[i]-'a';
if(!nee[root][ch])
return false;
root=nee[root][ch];
}
return over2[root];
}
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s;
insert();
}
int m;
cin>>m;
for(int i=0;i<m;i++)
{
cin>>s;
if(check1()&&(!check2()))
{
cout<<"OK\n";
insert2();
}
else if(check1()&&check2())
{
cout<<"REPEAT\n";
}
else
{
cout<<"WRONG\n";
}
}
return 0;
}