Untitled
raw download clone
C
views 31
,
size 1117 b
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[100005];
char b[100005];
char A[100005];
char B[100005];
int f(char a[], char b[], int al, int ar, int bl, int br){
    int i, j;
    for(i=1;i<=(ar-al+1);i++){
        A[i] = a[i];
    }
    for(i=1;i<=(br-bl+1);i++){
        B[i] = b[i];
    }
    i = 1;
    while(i<=(ar-al+1)){
        if(A[i] == B[i]) j++;
        if(j == (ar-al+1)) return 1;
        else printf("%c%c\n", A[i], B[i]);
        i++;
    }
    if(((ar-al+1)%2 == 1)&&((br-bl+1)%2 == 1)) return 0;
        else{
            int amid = (al+ar)/2;
            int bmid = (bl+br)/2;
            if (f(A, B, al, amid, bl, bmid) && f(A, B, amid, ar, bmid, br))
                return 1;
            else if (f(A, B, al, amid, bmid, br) && f(A, B, amid, ar, bl, bmid))
                return 1;
            else
                return 0;
        }
}
int main ( ){
    int i, len;
    scanf("%s%s", a, b);
    len = strlen(a);
    if(f(a, b, 0, len-1, 0, len-1))
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.