/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 2ms 764.0 KiB
#4 Accepted 2ms 320.0 KiB
#5 Accepted 2ms 764.0 KiB

Code

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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  
  int Q; cin >> Q;
  while (Q--)[&] {
    int n;    cin >> n;
    string s, t;
    cin >> s >> t;

    // int l = 0, r = n-1;
    // while (l < n && s[l] == t[l]) l++;
    // while (r >= 0 && s[r] == t[r]) r--;

    // if (r == -1) {
    //   cout << "YES\n";
    //   return;
    // }

    for (int i = 0; i < n-1; i++) {
      if (s[i] != t[i]) {
        if (t[i] == '0') s[i] = '0', s[i + 1] = '1';
        else s[i] = '1', s[i + 1] = '0';
      }
    } 

    for (int i = n-1; i > 0; --i) {
      if (s[i] != t[i]) {
        if (t[i] == '0') s[i] = '0', s[i - 1] = '1';
        else s[i] = '1', s[i - 1] = '0';
      }
    }

    cout << (s == t ? "YES" : "NO") << "\n";
  }();
}

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:53:35
Judged At
2026-01-06 14:53:36
Judged By
Score
100
Total Time
2ms
Peak Memory
764.0 KiB