Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- using namespace std;
- int toNumber(const string &x) {
- int res = 0;
- for (char i : x) {
- res = res * 10 + i - '0';
- }
- return res;
- }
- int main() {
- // freopen("output.txt", "w", stdout);
- ios::sync_with_stdio(0);
- cin.tie();
- int n = 0;
- string s;
- map<string, bool> words;
- while (cin >> s) {
- if (s[0] >= '0' && s[0] <= '9') {
- break;
- }
- n++;
- words[s] = true;
- }
- int q = toNumber(s);
- for (int i = 0; i < q; ++i) {
- string word;
- cin >> word;
- string new_word = word;
- for (int k = 0; k < 26; ++k) {
- for (int j = 0; j < word.size(); ++j) {
- new_word[j] = (word[j] - 'a' + k) % 26 + 'a';
- }
- if (words[new_word]) {
- cout << new_word << "\n";
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement