/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 488.0 KiB
#3 Wrong Answer 2ms 348.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 = [&]() {
            if(n & 1) {
                cout << "NO\n"; return;
            }
            int cnt = count(p.begin(), p.end(), '0');
            int cnt1 = n - cnt;
            if(cnt == 0 or cnt1 == 0) {
                cout << "NO\n"; return;
            }
            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 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:40:55
Judged At
2026-01-06 14:40:56
Judged By
Score
0
Total Time
2ms
Peak Memory
532.0 KiB