/ 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 320.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int n;
string s, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt;
    cin >> tt;
    while (tt--)
    {
        cin >> n >> s >> t;
        if (s == t)
        {
            cout << "YES\n";
            continue;
        }
        if(n==1){
            cout<<"NO\n";
            continue;
        }
        vector<int> v(n);
        v[0] = (t[0] == t[1]);
        v[n - 1] = (t[n - 1] == t[n - 2]);
        for (int i = 1; i < n - 1; i++)
        {
            if (t[i] == t[i + 1] and t[i] == t[i - 1])
                v[i] = 1;
        }
        f(i,n){
            if(v[i] and s[i]!=t[i]){
                cout<<"NO\n";
                goto end;
            }
        }
        cout << "YES\n";
    end:;
    }

    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:57:19
Judged At
2026-01-06 15:57:19
Judged By
Score
0
Total Time
2ms
Peak Memory
532.0 KiB