Untitled
raw download clone
C
views 30
,
size 1131 b
#include<stdio.h>
#include<string.h>

char a[100002], b[100002];
int lena, lenb;
int compare(char c[100002], char d[100002], int al, int ar, int bl, int br);

int main(void){
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	if(compare(a, b, 0, lena-1, 0, lenb-1)) printf("YES\n");
	else printf("No\n");

	return 0;
}

int amid, bmid, i;
char newa[100002], newb[100002];

int compare(char c[100002], char d[100002], int al, int ar, int bl, int br){
	if (strcmp(c, d) == 0) return 1;
	else if(lena % 2 == 1) return 0;
	else if(al == ar) return 0;
	else {
		amid = (al+ar)/2;
		bmid = (bl+br)/2;
		printf("al = %d, ar = %d\n", al, ar);
		printf("amid = %d\n", amid);
		for(i=al; i<ar; i++){
			newa[i] = c[i];
			printf("newa[%d] = %c\n", i ,newa[i]);
		}
		for(i=bl; i<br; i++){
			newb[i] = d[i];
			printf("newb[%d] = %c\n", i ,newb[i]);
		}
		if(compare(newa, newb, al, amid, bl, bmid) || compare(newa, newb, amid, ar, bmid, br) || compare(newa, newb, al, amid, bmid, br) || compare(newa, newb, amid, ar, bl, bmid)) return 1;
		else return 0;
	}
	return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.