Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1e6 + 3;
  5. unordered_set <string> use;
  6. string word;
  7.  
  8. int
  9. main(void)
  10. {
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(); cout.tie();
  13. //freopen("input", "r", stdin);
  14. //freopen("output", "w", stdout);
  15.  
  16. string s;
  17. getline(cin, s);
  18. int n;
  19. stringstream in(s);
  20. while (in >> word) use.insert(word);
  21.  
  22. cin >> n;
  23. for (int i = 0; i < n; ++i) {
  24. cin >> s;
  25. for (int j = 0; j < 26; ++j) {
  26. for (auto& let : s) {
  27. let = (let - 26) + 1;
  28. if (let < 'a') {
  29. let += 26;
  30. }
  31. }
  32. auto ans = use.find(s);
  33. if (ans != use.end()) {
  34. cout << *ans << endl;
  35. break;
  36. }
  37. }
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement