Untitled
raw download clone
TEXT
views 28
,
size 818 b
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char a[100005], b[100005];
int check(int al, int ar, int bl, int br);
int check(int al, int ar, int bl, int br){

int len, i, j;
int amid, bmid;
len=ar-al+1;

for(i=al; i<=ar; i++){
    for(j=bl; j<=br; j++)
    {
        if(a[i]!=b[j]) break;
        else if(i == ar) return 1;
    }
    if(a[i]!=b[j]) break;
}
if(len%2==1){return 0;}
else{
    amid=(al+ar)/2;
    bmid=(bl+br)/2;
    if(check(al, amid, bl, bmid) && (check(amid+1, ar, bmid+1, br))) return 1;
    else if(check(al, amid, bmid+1, br) && (check(amid+1, ar, bl, bmid))) return 1;
    else return 0;
    }
}

int main()
{
 int len=strlen(a);
 scanf("%s %s", &a, &b);
 if(check(0,len, 0, len))printf("YES");
 else printf("NO");
 printf("\n");
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.