1 solutions

  • 0
    @ 2023-11-1 16:01:13

    题解后面补,先放个c++的

    #include <algorithm>
    #include <iostream>
    #include <string>
    using namespace std;
    
    int flag=1;
    
    bool f(string s, string t) {
        if(flag==0)return false;
        if (s == t)
            return true;
        string b=t;
        reverse(b.begin(), b.end());
        if (s == b)
            return true;
        int l1=s.length(),l2=t.length();
        if(l1%2==0)return f(s.substr(0,l1/2),t.substr(0,l2/2))&&f(s.substr(l1/2,l1/2),t.substr(l2/2,l2/2));
        return false;
    }
    
    int main() {
        string s, t;
        cin >> s >> t;
        if (f(s, t)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    }
    
    • 1

    Information

    ID
    6948
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    # Submissions
    194
    Accepted
    12
    Uploaded By