-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path313B.cpp
More file actions
60 lines (56 loc) · 1.25 KB
/
313B.cpp
File metadata and controls
60 lines (56 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int funct(string s,string t,int len){
int res = 0;
for(int i=0,j=len-1;i<len&&j>=0;i++,j--){
if(s[i]!=t[j]) return -1;
}
return 1;
}
int div(string s,string t,int len){
if(len == 1){
if(s==t) return 1;
else return -1;
}
int a= len/2;
int b = len - len/2;
string s1 = s.substr(0,a);
string s2 = s.substr(a,b);
string t1 = t.substr(0,b);
string t2 = t.substr(b,a);
cout<<s1<<" "<<s2<<" "<<t1<<" "<<t2<<endl;
int ret = 0;
ret = div(s1,t2,a);
if(ret == -1) return -1;
ret = div(s2,t1,b);
if(ret == -1) return -1;
return 1;
}
string small(string s){
if(s.length()%2==1) return s;
string s1 = small(s.substr(0,s.length()/2));
string s2 = small(s.substr(s.length()/2,s.length()));
//cout<<s1<<" "<<s2<<endl;
if(s1<s2) return s1+s2;
return s2+s1;
}
int main(){
// accepted
string s1,s2;
cin>>s1;
cin>>s2;
//int l = s1.size();
//int r = div(s1,s2,l);
string t1 = small(s1);
string t2 = small(s2);
//sort(s1.begin(),s1.end());
// sort(s2.begin(),s2.end());
if(t1==t2){
printf("YES\n");
}
else{
printf("NO\n");
}
}