0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-05 06:38:48 +00:00
OI-codes/S2OJ/1033/1033.cpp

39 lines
961 B
C++

#include <bits/stdc++.h>
using namespace std;
int t;
bool ans, flag[26][26];
string a, b;
int main() {
cin >> t;
getline(cin, a);
while (t--) {
memset(flag, 0x00, sizeof(flag));
getline(cin, a);
getline(cin, b);
ans = a.size() == b.size();
if (ans) {
for (int i = 0; i < a.size(); i++) {
if (a[i] == b[i]) continue;
if ('a' > a[i] || a[i] > 'z' || 'a' > b[i] || b[i] > 'z') {
ans = false;
break;
}
for (int j = 0; j < 26; j++) {
if (flag[a[i] - 'a'][j]) {
if (j != b[i] - 'a') {
ans = false;
break;
}
}
}
flag[a[i] - 'a'][b[i] - 'a'] = 1;
}
}
cout << ans << endl;
}
return 0;
}