替换函数
#pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #include<queue> #include<stack> #include<string> #include<functional> #include<math.h> //#include<bits/stdc++.h> using namespace std; typedef long long lint; typedef vector<int> VI; typedef pair<int, int> PII; typedef queue<int> QI; void makedata() { freopen("input.txt", "w", stdout); fclose(stdout); } string s, d; char f[256]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif //makedata(); std::ios::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t--) { cin >> s >> d; int n = s.length(); memset(f, 0, sizeof(f)); bool ok = true; for (int i = 0; i < n; i++) { if (f[s[i]] == 0) f[s[i]] = d[i]; else if (f[s[i]] != d[i]) ok = false; } if (ok) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }