/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Wrong Answer 2ms 568.0 KiB

Code

#include <bits/stdc++.h>     //   All praise is due to Allah alone, and peace and blessings be
using namespace std;         //         upon him, after whom there is no other Prophet.

int32_t main() {
    cin.tie(0)->sync_with_stdio(false);

    int32_t Case = 1;    cin >> Case;
    for (int T = 1; T <= Case; T++) {

        int n; cin >> n;
        string s, p; cin >> s >> p;

        if(s == p) {
            cout << "YES\n"; continue;
        }

        function<void()> Test_Case = [&]() {
            string ns = s, np = p;
            for(int i = 0; i < n - 1; i++) {
                if(s[i] != p[i]) {
                    if(s[i] == '0') {
                        s[i] = '1', s[i + 1] = '0';
                    }
                    else {
                        s[i] = '0', s[i + 1] = '1';
                    }
                }
            }
            if(s.back() == p.back()) cout << "YES\n";
            else {
                s = ns, p = np;
                for(int i = n - 1; i > 0; i--) {
                    if(s[i] != p[i]) {
                        if(s[i] == '0') {
                            s[i] = '1', s[i - 1] = '0';
                        }
                        else {
                            s[i] = '0', s[i - 1] = '1';
                        }
                    }
                }
                if(s.front() == p.front()) {
                    cout << "YES\n";
                }
                else cout << "NO\n";
            }
        };
        Test_Case();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1233 B. Make Binary Strings Equal
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 14:43:06
Judged At
2026-01-06 14:43:06
Judged By
Score
0
Total Time
2ms
Peak Memory
568.0 KiB