#include <bits/stdc++.h>
using namespace std;
struct data{
int sz;
string word;
}dic[10003];
int main(){
string words;
int t;
map <string, int> M;
cin >> t;
while(t--){
M.clear();
int i = 0;
for(i = 0; ; i++){
cin >> words;
if(words == "#")break;
M[words] = 1;
dic[i].word = words;
dic[i].sz = words.size();
}
for(int j = 0; ; j++){
cin >> words;
if(words == "#")break;
if(M[words]){
cout << words << " is correct" << endl;
continue;
}
int szz = words.size();
cout << words <<":";
for(int k = 0; k < i; k++){
int cn;
if(szz == dic[k].sz){
cn = 0;
for(int m = 0; m < szz; m++){
if(words[m] != dic[k].word[m]){
cn++;
}
}
if(cn <= 1)cout << " " << dic[k].word;
}
else if(abs(szz-dic[k].sz) == 1){
if(szz > dic[k].sz){
cn = 0;
for(int m = 0, n = 0; m < szz; m++, n++){
if(words[m] != dic[k].word[n])cn++, n--;
}
if(cn <= 1)cout << " " << dic[k].word;
}
else{
cn = 0;
for(int m = 0, n = 0; n < dic[k].sz; m++, n++){
if(words[m] != dic[k].word[n])cn++, m--;
}
if(cn <= 1)cout << " " << dic[k].word;
}
}
}
cout << endl;
}
if(t)cout << endl;
}
return 0;
}
using namespace std;
struct data{
int sz;
string word;
}dic[10003];
int main(){
string words;
int t;
map <string, int> M;
cin >> t;
while(t--){
M.clear();
int i = 0;
for(i = 0; ; i++){
cin >> words;
if(words == "#")break;
M[words] = 1;
dic[i].word = words;
dic[i].sz = words.size();
}
for(int j = 0; ; j++){
cin >> words;
if(words == "#")break;
if(M[words]){
cout << words << " is correct" << endl;
continue;
}
int szz = words.size();
cout << words <<":";
for(int k = 0; k < i; k++){
int cn;
if(szz == dic[k].sz){
cn = 0;
for(int m = 0; m < szz; m++){
if(words[m] != dic[k].word[m]){
cn++;
}
}
if(cn <= 1)cout << " " << dic[k].word;
}
else if(abs(szz-dic[k].sz) == 1){
if(szz > dic[k].sz){
cn = 0;
for(int m = 0, n = 0; m < szz; m++, n++){
if(words[m] != dic[k].word[n])cn++, n--;
}
if(cn <= 1)cout << " " << dic[k].word;
}
else{
cn = 0;
for(int m = 0, n = 0; n < dic[k].sz; m++, n++){
if(words[m] != dic[k].word[n])cn++, m--;
}
if(cn <= 1)cout << " " << dic[k].word;
}
}
}
cout << endl;
}
if(t)cout << endl;
}
return 0;
}
No comments:
Post a Comment