题意:定义了字符串的相等,问两串是否相等。
卡了时间,空间,不能新建字符串,否则会卡。
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
using namespace std;
const int SZ=1e7+,INF=0x7FFFFFFF;
typedef long long lon;
string x,y; bool cmp(int bg1,int end1,int bg2,int end2)
{
for(int i=bg1,j=bg2;i<end1;++i,++j)
{
if(x[i]!=y[j])return ;
}
return ;
} bool equ(int bg1,int end1,int bg2,int end2,int d)
{
int len=end1-bg1;
//cout<<d<<"cmp: "<<bg1<<" "<<end1<<" "<<bg2<<" "<<end2<<" "<<cmp(bg1,end1,bg2,end2)<<endl;
if(cmp(bg1,end1,bg2,end2)==)return ;
else if((len)&)return ;
else
{
int half=len/;
return (equ(bg1,bg1+half,bg2,bg2+half,d+)&&equ(bg1+half,end1,bg2+half,end2,d+)||equ(bg1,bg1+half,bg2+half,end2,d+)&&equ(bg1+half,end1,bg2,bg2+half,d+));
}
} int main()
{
std::ios::sync_with_stdio();
cin>>x>>y;
if(equ(,x.size(),,y.size(),))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}