12133 - Yes papa
raw download clone
C
views 24
,
size 1038 b
#include <stdio.h>

int check(int s1, int e1, int s2, int e2);

char a[100001], b[100001];

int main(void)
{
    int l = 0;
    char c;

    while((c = getchar()) != '\n')
    {
        l++;
        a[l] = c;
    }
    l = 0;
    while((c = getchar()) != '\n')
    {
        l++;
        b[l] = c;
    }
    if(check(1, l, 1, l) == 0)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}

int check(int s1, int e1, int s2, int e2)
{
    int flag = 1;
    for(int i=s1, j=s2; i<=e1; i++, j++)
    {
        if(a[i] != b[j])
        {
            flag = 0;
            break;
        }
    }
    if(flag == 1)
        return 1;
    else if((e1 - s1 + 1) % 2 == 1)
        return 0;
    else if(check(s1, (s1 + e1 - 1) / 2, s2, (s2 + e2 - 1) / 2) * check((s1 + e1 + 1) / 2, e1, (s2 + e2 + 1) / 2, e2) == 1)
        return 1;
    else if(check(s1, (s1 + e1 - 1) / 2, (s2 + e2 + 1) / 2, e2) * check((s1 + e1 + 1) / 2, e1, s2, (s2 + e2 - 1) / 2) == 1)
        return 1;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.