/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include <bits/stdc++.h>
using namespace std;

bool check(int st, int en, int inc, string s, string &p) {
    for (int i = st; min(st, en) <= i && i <= max(st, en); i += inc) {
        if (s[i] != p[i]) {
            s[i] = p[i];
            s[i + inc] = p[i] ^ '0' ^ '1';
        }
    }
    // cout << st << " " << en << " " << (s == p) << endl;
    return (s == p);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    #ifdef SUBLIME
        freopen("inputf.in", "r", stdin);
        freopen("outputf.out", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif

    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        string s, p;
        cin >> n >> s >> p;
        if (n == 1) {
            if (s != p) cout << "NO\n";
            else cout << "YES\n";
            continue;
        }
        cout << ((check(0, n - 2, 1, s, p) || check(n - 1, 1, -1, s, p)) ? "YES" : "NO") << "\n";
    }
    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 15:10:46
Judged At
2026-01-06 15:10:46
Judged By
Score
0
Total Time
2ms
Peak Memory
764.0 KiB