/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 2ms 532.0 KiB
#4 Accepted 2ms 532.0 KiB
#5 Accepted 2ms 532.0 KiB

Code

                            /*in the name of almighty ALLAH*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define MOD2 987654319
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(x) (int)x.size()

template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using multi_pbds = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

//***********************************START*******************************************//

void solve()
{
    int n; cin >> n;
    string a, b; cin >> a >> b;
    int ona = count(all(a), '1'), za = n - ona, onb = count(all(b),'1'), zb = n - onb;

    if(onb > ona){
        if(onb - ona <= (za - 1)) yes;
        else no;
    }
    else if(onb < ona){
        if(zb - za <= (ona - 1)) yes;
        else no;
    }
    else yes;

}

//***********************************END*********************************************//
int32_t main(){ fast

    int32_t t = 1, i;
      cin >> t;
    for(i = 1; i <= t; i++)
    {
       // cout << "Case " << i << ": ";
        solve();
    }
}

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:56:32
Judged At
2026-01-06 14:56:32
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB