样例输入:
abbaabba
baababab
样例输出:
YES
1,String 函数大集合
(1),s.size()
(2),sort(s.begin,s.end)
sort(s.begin()+x,s.end()-y)
(3),s.push_back('a')//尾部插字符
(4),s.insert(s.begin(),'1'); ///自定义位置插入字符
s.inser(s.begin()+3,'a')//在第三个字符后添加,只能这么写
(5),s.substr(3,6)//截取字符串,共截6个字符
return half(a1,b1) && half(a2,b2) || half(a1,b2)
&& half(a2,b1);
#include <bits/stdc++.h>
using namespace std;
bool half(string s1,string s2){
if(s1 == s2){
return true;
}else if(s1.size() % 2 == 0 && s1.size() == s2.size()){
string a1,a2,b1,b2;
a1 = s1.substr(0,s1.size() / 2);
a2 = s1.substr(s1.size() / 2,s1.size() / 2);
b1 = s2.substr(0,s2.size() / 2);
b2 = s2.substr(s2.size() / 2,s2.size() / 2);
return half(a1,b1) && half(a2,b2) || half(a1,b2) && half(a2,b1);
}else return false;
}
int main(){
string s1,s2;
cin >> s1 >> s2;
if(half(s1,s2)){
cout << "YES" << endl;
}else cout << "NO" << endl;
return 0;
}