#include<bits/stdc++.h>
using namespace std;
bool time_[500010];
bool end_[500010];
int len;
int to[200][500010];
void add(){
char c=getchar();
int now=0;
while(c>=97&&c<=122){
if(to[c][now]==0){
len++;
to[c][now]=len;
}
now=to[c][now];
c=getchar();
}
end_[now]=1;
}
void meaning(){
char c=getchar();
while(c>=97&&c<=122){
c=getchar();
}
}
void find(){
char c=getchar();
int now=0;
while(c>=97&&c<=122){
if(to[c][now]==0){
meaning();
printf("WRONG\n");
return;
}
else{
now=to[c][now];
c=getchar();
}
}
if(end_[now]){
if(time_[now]) printf("REPEAT\n");
else{
printf("OK\n");
time_[now]=1;
}
}
else printf("WRONG\n");
}
int main(){
//freopen("P2580_1.in","r",stdin);
//freopen("1.txt","w",stdout);
int n;
scanf("%d\n",&n);
for(int i=1;i<=n;i++) add();
int m;
scanf("%d\n",&m);
for(int i=1;i<=m;i++) find();
return 0;
}
本地测第一个点、样例过了
在线测了5次,WA和OLE都有,同样的代码每次错误不一样
求大佬解答