You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
796 B
48 lines
796 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
bool issimilar(string a, string b) {
|
|
if (abs((int)a.size() - (int)b.size()) > 1)
|
|
return false;
|
|
if (a.size() == b.size()) {
|
|
int cnt = 0;
|
|
for (int i = 0; i < a.size(); i++) {
|
|
if (a[i] != b[i])
|
|
if (cnt++ > 1)
|
|
return false;
|
|
}
|
|
return true;
|
|
} else {
|
|
int cnt = 0;
|
|
if (a.size() > b.size())
|
|
swap(a, b);
|
|
int j = 0;
|
|
for (int i = 0; i < a.size();) {
|
|
if (a[i] != b[j]) {
|
|
cnt++;
|
|
j++;
|
|
} else {
|
|
i++;
|
|
j++;
|
|
}
|
|
}
|
|
if (cnt > 1)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int T;
|
|
cin >> T;
|
|
while (T--) {
|
|
string a, b;
|
|
cin >> a >> b;
|
|
if (issimilar(a, b)) {
|
|
cout << "similar" << endl;
|
|
} else
|
|
cout << "not similar" << endl;
|
|
}
|
|
return 0;
|
|
}
|