Advertisement
Guest User

tsk905, again...

a guest
Jan 28th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #define loop(i,from,to) for (int i = from; i < to; ++i)
  2. #define qAll(q) q.begin(), q.end()
  3. #include <bits/stdc++.h>
  4.    
  5. using std::cin;
  6. using std::cout;
  7. using std::endl;
  8. using std::vector;
  9. using std::string;
  10. using std::tuple;
  11. using std::map;
  12.  
  13. const int INF = 1e9+7;
  14. const double eps = 1e-6;
  15. template <typename T> void reverse(T &a) {
  16.   long long s = a.size();
  17.   for (long long i = 0; i < s / 2; ++i)
  18.     std::swap(a[i], a[s - i - 1]);
  19. }
  20. string key = "the quick brown fox jumps over the lazy dog";
  21. int L = key.length();
  22. map<char, char> dict;
  23.  
  24.  
  25. bool check(string s) {
  26.   dict[' '] = ' ';
  27.   loop(i, 0, L)
  28.     if (!dict.count(s[i]) || dict[s[i]] == key[i])
  29.       dict[s[i]] = key[i];
  30.     else {
  31.       dict.clear();
  32.       return false;
  33.     }
  34.   return true;
  35. }
  36.  
  37. void modify(vector<string> &A) {
  38.   loop(i, 0, (int)A.size())
  39.     for (auto &z: A[i])
  40.       z = dict[z];
  41. }
  42.  
  43. signed main() {
  44.   std::ios::sync_with_stdio(false);
  45.   cin.tie(0);
  46.   int n; cin >> n;
  47.   string pta;
  48.   vector<string> data;
  49.   bool flag = false;
  50.   loop(i, 0, n) {
  51.     getline(cin >> std::ws, pta);
  52.     data.push_back(pta);
  53.     if (pta.length() == L && !flag)
  54.       if (check(pta))
  55.         flag = true;
  56.   }
  57.   if (flag) {
  58.     modify(data);
  59.     for (auto y: data)
  60.       cout << y << endl;
  61.   }
  62.   else cout << "No solution";
  63.   //std::cout << "Hello World!\n";
  64.   return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement