Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <unordered_map>
- using namespace std;
- bool check_string(string a, string b) {
- if (a.length() != b.length()) {
- return false;
- }
- unordered_map<char, char>letters;
- for (int i = 0; i < a.length(); ++i) {
- letters[a[i]] = b[i];
- letters[b[i]] = a[i];
- }
- string result_str;
- for (char i : a) {
- result_str += letters[i];
- }
- return result_str == b;
- }
- int main() {
- int n;
- cin >> n;
- vector<string>pair(2, "");
- for (int i = 0; i < n; ++i) {
- cin >> pair[0] >> pair[1];
- cout << (check_string(pair[0], pair[1]) ? "YES\n" : "NO\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement