1921B - Arranging Cats - CodeForces Solution


implementation

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define F first
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define S second
#define all(x) x.begin(),x.end()
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t; cin>>t; while(t--)
#define int ll
using namespace std;
const int N = 4e5+18,MOD=1e9+7;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
ll power(ll x,ll y)
{
    if(y==0) return 1;
    ll ww=power(x,y/2);
    if(y&1) return ww*ww*x;
    return ww*ww;
}
void solve()
{
    int n;
    string s,d;
    cin>>n>>s>>d;
    int a1=0,a2=0,a3=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]==d[i])
        continue;
        if(s[i]=='1') a1++;
        if(s[i]=='0'&&d[i]=='1')
            a2++;
    }
    cout<<max(a1,a2)<<endl;
}
int32_t main()
{
    FAST;
   T
    solve();
}


Comments

Submit
0 Comments
More Questions

383. Ransom Note
242. Valid Anagram
141. Linked List Cycle
21. Merge Two Sorted Lists
203. Remove Linked List Elements
733. Flood Fill
206. Reverse Linked List
83. Remove Duplicates from Sorted List
116. Populating Next Right Pointers in Each Node
145. Binary Tree Postorder Traversal
94. Binary Tree Inorder Traversal
101. Symmetric Tree
77. Combinations
46. Permutations
226. Invert Binary Tree
112. Path Sum
1556A - A Variety of Operations
136. Single Number
169. Majority Element
119. Pascal's Triangle II
409. Longest Palindrome
1574A - Regular Bracket Sequences
1574B - Combinatorics Homework
1567A - Domino Disaster
1593A - Elections
1607A - Linear Keyboard
EQUALCOIN Equal Coins
XOREQN Xor Equation
MAKEPAL Weird Palindrome Making
HILLSEQ Hill Sequence