#include <iostream>
using namespace std;
const int maxn = 1e+5;
struct node {
char c;
bool end;
int num;
int son[26];
}trie[maxn];
int n, m, cnt = 1;
int index(char c) {
return c - 'a';
}
void and_trie(string& str) {
int cur = 1;
int len = str.length();
for (int i = 0; i < len; i++) {
if (trie[cur].son[index(str[i])] == 0) { // 取到每一个字符
++cnt;
trie[cur].son[index(str[i])] = cnt;
}
cur = trie[cur].son[index(str[i])];
}
trie[cur].end = true;
}
void query_trie(string& str) {
int cur = 1;
int len = str.length();
for (int i = 0; i < len; i++) {
if (trie[cur].son[index(str[i])] == 0) {
cout << "WRONG" << endl;
return;
}
cur = trie[cur].son[index(str[i])];
}
if (trie[cur].end) {
if (trie[cur].num == 0) {
cout << "OK" << endl;
trie[cur].num++;
} else {
cout << "REPEAT" << endl;
}
} else {
cout << "WRONG" << endl;
}
return;
}
int main() {
cin >> n;
string tmp;
for (int i = 1; i <= n; i++) {
cin >> tmp;
and_trie(tmp);
}
cin >> m;
for (int i = 1; i <= m; i++) {
cin >> tmp;
query_trie(tmp);
}
return 0;
}
报错信息