/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 138ms 15.598 MiB
#2 Wrong Answer 131ms 15.641 MiB
#3 Wrong Answer 131ms 15.625 MiB

Code

#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("O3")

typedef long long ll;
typedef unsigned int ull;
typedef long double lld;

#define int long long

/*---------------------------------------------------------------------------------------------------------------------------------------------*/
#ifdef ONLINE_JUDGE
#define debug(x)
#else
#define debug(x)     \
  cerr << #x << " "; \
  _print(x);         \
  cerr << endl;
#endif

#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio()                    \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define setbits(x) __builtin_popcountll(x)

#define MOD 1000000007

void _print(ll t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
  cerr << "{";
  _print(p.ff);
  cerr << ",";
  _print(p.ss);
  cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
  cerr << "[ ";
  for (T i : v)
  {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v)
{
  cerr << "[ ";
  for (T i : v)
  {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
  cerr << "[ ";
  for (T i : v)
  {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
  cerr << "[ ";
  for (auto i : v)
  {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}

int ceilCustom(int a, int b)
{
  return (a + b - 1) / b;
}

vector<int> vinput(int n)
{
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  return v;
}

void printVector(vector<int> &v)
{
  for (int i = 0; i < v.size(); i++)
  {
    cout << v[i] << " ";
  }
  cout << '\n';
}

bool isPrime(int num)
{
  if (num <= 1)
  {
    return false;
  }

  if (num <= 3)
  {
    return true;
  }

  if (num % 2 == 0 || num % 3 == 0)
  {
    return false;
  }

  for (int i = 5; i * i <= num; i += 6)
  {
    if (num % i == 0 || num % (i + 2) == 0)
    {
      return false;
    }
  }
  return true;
}

long long modpow(long long a, long long b)
{
  long long res = 1;
  a %= MOD;
  while (b > 0)
  {
    if (b & 1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

long long modinv(long long q)
{
  return modpow(q, MOD - 2);
}

// long long ans = (p * modinv (q)) % MOD ;

/*---------------------------------------------------------------------------------------------------------------------------------------------*/

long long floor_div(long long a, long long b)
{
  long long q = a / b;
  long long r = a % b;
  if (r != 0 && ((r > 0) != (b > 0)))
    q--;
  return q;
}

int rev(int x)
{
  int ans = 0;
  while (x > 0)
  {
    int dig = x % 10;
    ans = ans * 10 + dig;
    x /= 10;
  }
  return ans;
}
const int N = 1e6 + 5; // Adjust according to constraints

/* Factorial and Binomial COeffecient */
int fact[N], inv_fact[N];

// Fast exponentiation: (a^b) % m
int power(int a, int b, int mod) {
    int res = 1;
    a %= mod;
    while (b > 0) {
        if (b & 1) // if ood (a ^ (n/2)) ^ 2 * a
            res = (int)((1LL * res * a) % mod);
        a = (int)((1LL * a * a) % mod);
        b >>= 1; // divide by 2
    }
    return res;
}

// Precompute factorials and inverse factorials
void precompute() {
    fact[0] = inv_fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
        inv_fact[i] = power(fact[i], MOD - 2, MOD); // Fermat's little theorem
    }
}

// Compute C(n, k) mod MOD
int binomial(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * inv_fact[k] % MOD * inv_fact[n - k] % MOD;
}


int ask(int x, int y) {
  cout << "? " << x << " " << y << endl;
  int ans;
  cin >> ans;
  return ans;
}


void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;

  if (n == 1) {
    if (s == t) {
      cout << "YES\n";
    }
    else {
      cout << "NO\n";
    }
    return ;
  }

  for (int i = 0; i < n-1; i++) {
    string subs = s.substr(i, 2);
    string subt = t.substr(i, 2);
    if (subt == subs) continue ;
    if (subt == "01" || subt == "10") {
      continue;
    }
    else {
      cout << "NO\n";
      return ;
    }
  }
  cout << "YES\n";
}

/*
- 
*/

signed main()
{
  precompute();
  fastio();
  int t = 1;
  cin >> t;
  while (t--)
  {
    solve();
  }

  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 16:51:53
Judged At
2026-01-06 16:51:53
Judged By
Score
0
Total Time
138ms
Peak Memory
15.641 MiB