Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "bits/stdc++.h"
- #include <iostream>
- #include <sstream>
- #include <vector>
- #include <unordered_map>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair<ll, ll> pll;
- typedef pair<ld, ld> pld;
- typedef pair<int, int> pii;
- #define FOR(i, n) for (int i = 0; i < n; i++)
- #define PI acos(-1)
- #define x first
- #define y second
- string parse_word(string const& s)
- {
- string ret = "#";
- for (int i = 0; i < s.size() - 1; ++i)
- {
- ll dif = s[i + 1] - s[i];
- if (dif < 0)
- {
- dif += 26;
- }
- ret += char(int('a') + dif);
- }
- return ret;
- }
- /**
- a abb bab abc
- 6
- q
- bcc
- aza
- abc
- z
- def
- aza --> bab
- */
- int main()
- {
- cin.tie(nullptr);
- ios::sync_with_stdio(false);
- unordered_map<string, string> _difmap;
- string s;
- getline(cin, s);
- stringstream ss(s);
- string word;
- while (ss >> word)
- {
- string v = parse_word(word);
- _difmap[v] = word;
- }
- int n;
- cin >> n;
- FOR(i, n)
- {
- string tmp_in;
- cin >> tmp_in;
- string tmp_string = parse_word(tmp_in);
- cout << _difmap[tmp_string] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement