Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 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();
  13. cout.tie();
  14.  
  15. string s;
  16. int n;
  17. getline(cin, s);
  18. cin >> n;
  19. stringstream in(s);
  20. while (in >> word) use.insert(word);
  21.  
  22. for (int i = 0; i < n; ++i) {
  23. cin >> s;
  24. for (int j = 0; j < 26; ++j) {
  25. for (auto& let : s) {
  26. let = (let - 26) + 1;
  27. if (let < 'a') {
  28. let += 26;
  29. }
  30. }
  31. auto ans = use.find(s);
  32. if (ans != use.end()) {
  33. cout << *ans << '\n';
  34. break;
  35. }
  36. }
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement