Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_map>
  3.  
  4. using namespace std;
  5.  
  6. string normalize(std::string& s) {
  7. char c = s[0];
  8. string t = "";
  9. for (int i = 0; i < s.size(); i++) {
  10. t += (s[i] + 26 - c) % 26 + 'a';
  11. }
  12. return t;
  13. }
  14.  
  15. int main() {
  16. std::ios_base::sync_with_stdio(false);
  17. cin.tie(nullptr);
  18. string s;
  19. getline(cin, s);
  20. unordered_map<string, string> st;
  21. string v;
  22. for (int i = 0; i < s.size(); i++) {
  23. if (s[i] == ' ') {
  24. st[normalize(v)]= v;
  25. v = "";
  26. } else {
  27. v += s[i];
  28. }
  29. }
  30. st[normalize(v)]= v;
  31. int n;
  32. std::cin >> n;
  33. string t[n];
  34. for (int i = 0; i < n; i++) {
  35. std::cin >> t[i];
  36. cout << st[normalize(t[i])] << '\n';
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement