const int MX = 1e4 + 10;
int tot,cnt[MX*55],son[MX*55][55];
void build(string x)
{
int p=0;
for(auto c:x)
{
if(son[p][c-'a']==0) son[p][c-'a']=++tot;
p=son[p][c-'a'];
}
}
int check(string x)
{
int p=0;
for(auto c:x)
{
if(son[p][c-'a']==0) return 0;
p=son[p][c-'a'];
}
if(cnt[p]) return 1;
++cnt[p];
return 2;
}
signed main()
{
int n;cin>>n;
rpp(i,n)
{
string s;cin>>s;
build(s);
}
int m;cin>>m;
rpp(i,m)
{
string s;cin>>s;
int k=check(s);
if(k==0) cout<<"WRONG\n";
else if(k==1) cout<<"REPEAT\n";
else cout<<"OK\n";
}
stop;
return 0;
}
P2580 于是他错误的点名开始了 (一个板子)
最新推荐文章于 2024-05-10 18:41:04 发布