1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> pii;
#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define fi first #define se second #define mp make_pair #define np next_permutation #define pb puss_back #define endl '\n' #define all(x) x.begin(), x.end()
string a, b, c;
map<char, char> dic, dic2;
bool check() { dic.clear(); dic2.clear(); if (a.length() != b.length()) return false; rep(i, 0, a.length()) { if (dic.count(a[i])) { if (dic[a[i]] != b[i]) return false; } else { if (dic2.count(b[i]) && dic2[b[i]] != a[i]) return false; dic[a[i]] = b[i]; dic2[b[i]] = a[i]; } } if (dic2.size() == 26) return true; else return false; }
int main() { ios::sync_with_stdio(false); while (cin >> a >> b >> c) { if (!check()) cout << "Failed" << endl; else { rep(i, 0, c.length()) { cout << dic[c[i]]; } cout << endl; } } }
|