#include<iostream>
#include<cstdio>
#include<cstring>
#define R register
using namespace std;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch > '9' || ch < '0')
{
if(ch == '-')
f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int n, m, tree[500005][26], exist[500005], end[500005], tot;
char s[55];
void insert(char *s)
{
int len = strlen(s), p;
for(int i = 0; i < len; ++i)
{
int ch = s[i] - 'a';
if(!tree[p][ch])
tree[p][ch] = ++tot;
p = tree[p][ch];
}
end[p] = 1;
}
int search(char *s)
{
int len = strlen(s), p;
for(int i = 0; i < len; ++i)
{
int ch = s[i] - 'a';
if(!tree[p][ch])
return 0;
p = tree[p][ch];
}
if(end[p])
{
exist[p]++;
if(exist[p] != 1)
return 2;
else
return 1;
}
else
return 0;
}
int main()
{
n = read();
for(R int i = 1; i <= n; ++i)
{
cin>>s;
insert(s);
}
m = read();
while(m--)
{
cin >> s;
int opt = search(s);
if(opt == 1)
cout << "OK" << endl;
if(opt == 2)
cout << "REPEAT" << endl;
if(opt == 0)
cout << "WRONG" << endl;
}
return 0;
}
改成scanf就成10分了??