Codeforces Round #313 (Div. 2) Problem D - Equivalent Strings

来源:互联网 发布:手机淘宝快速秒杀器 编辑:程序博客网 时间:2024/05/06 23:46
93 ms   396 KB#include <iostream>#include <cstring>using namespace std;char A[200010];char B[200010];void fun(char C[], int N) {    if(N % 2 == 0) {        int nN = N/2;        fun(C,nN);        fun(C+nN,nN);        if(strncmp(C,C+nN,nN) > 0) for(int i=0;i<nN;i++) swap(C[i],C[nN+i]);    }}int main() {    cin >> A >> B;    int N = strlen(A);    fun(A,N);    fun(B,N);    if(strncmp(A,B,N) == 0) cout << "YES" << endl;    else cout << "NO" << endl;    return 0;}
0 0
原创粉丝点击