#include #include #include using namespace std; vector words; string deleted_char(const string& word, const int idx) { assert(0 <= idx && idx < word.size()); return word.substr(0, idx) + word.substr(idx + 1); } vector query(const string& s) { vector results; for (string word : words) { switch (static_cast(word.size()) - static_cast(s.size())) { case 1: { // 需要删 for (int i = 0; i < word.size(); i++) { if (word[i] != s[i]) { if (deleted_char(word, i) == s) { results.push_back(word); break; } } } break; } case -1: { for (int i = 0; i < s.size(); i++) { if (word[i] != s[i]) { if (deleted_char(s, i) == word) { results.push_back(word); break; } } } break; } case 0: { if (word == s) { return vector{word}; } int diff_count = 0; for (int i = 0; i < s.size(); i++) { if (word[i] != s[i]) { diff_count++; } if (diff_count > 1) { break; } } if (diff_count == 1) { results.push_back(word); break; } break; } default: break; } } return results; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; while (cin >> s && s[0] != '#') { words.push_back(s); } while (cin >> s && s[0] != '#') { vector results = query(s); if (!results.empty() && results[0] == s) { cout << s << " is correct" << endl; continue; } cout << s << ": "; for (const string& result : results) { cout << result << " "; } cout << endl; } return 0; }