parent
cf5b15d2b3
commit
1f61a81db3
Binary file not shown.
@ -0,0 +1,47 @@
|
|||||||
|
#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;
|
||||||
|
}
|
Loading…
Reference in new issue