Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define loop(i,from,to) for (int i = from; i < to; ++i)
- #define qAll(q) q.begin(), q.end()
- #include <bits/stdc++.h>
- using std::cin;
- using std::cout;
- using std::endl;
- using std::vector;
- using std::string;
- using std::tuple;
- using std::map;
- const int INF = 1e9+7;
- const double eps = 1e-6;
- template <typename T> void reverse(T &a) {
- long long s = a.size();
- for (long long i = 0; i < s / 2; ++i)
- std::swap(a[i], a[s - i - 1]);
- }
- string key = "the quick brown fox jumps over the lazy dog";
- int L = key.length();
- map<char, char> dict;
- bool check(string s) {
- dict[' '] = ' ';
- loop(i, 0, L)
- if (!dict.count(s[i]) || dict[s[i]] == key[i])
- dict[s[i]] = key[i];
- else {
- dict.clear();
- return false;
- }
- return true;
- }
- void modify(vector<string> &A) {
- loop(i, 0, (int)A.size())
- for (auto &z: A[i])
- z = dict[z];
- }
- signed main() {
- std::ios::sync_with_stdio(false);
- cin.tie(0);
- int n; cin >> n;
- string pta;
- vector<string> data;
- bool flag = false;
- loop(i, 0, n) {
- getline(cin >> std::ws, pta);
- data.push_back(pta);
- if (pta.length() == L && !flag)
- if (check(pta))
- flag = true;
- }
- if (flag) {
- modify(data);
- for (auto y: data)
- cout << y << endl;
- }
- else cout << "No solution";
- //std::cout << "Hello World!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement