#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define testcase \
ll tc, t = 1; \
cin >> tc; \
while (tc--)
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define vll vector<ll>
int main()
{
long long n = 0, m = 0, i = 0, j = 0, k = 0, l = 0, x = 0, y = 0;
string a, b;
cin >> n >> a >> b;
vector<long long> c0, c1;
for (i = 0; i < n; i++)
{
if (a[i] != b[i])
{
if (a[i] == '0')
c0.push_back(i);
else
c1.push_back(i);
}
}
k = c1.size() - c0.size();
ll ans = abs(k);
cout << c0.size() << " " << c1.size() << " " << k << "\n";
return 0;
}
tc.:
8
10001001
01101110
output
4 2 4294967294
when c0.size is 4 and c1.size is 2 then why k(c1.size() - c0.size()) stores 4294967294
This is because the value returned by XYZ.size() is unsigned (in this case unsigned long long) and when you do (c1.size()-c0.size()) it has value (2-4) so result is expected to be -2 but since both the operands with subtraction are unsigned long long so the result is also evaluated as unsigned long long. So how -2 is represented in unsigned long long? there are no negative numbers in unsigned long long, but it overflow so you get wrong result so before subtracting try to type cast in long long before subtracting to get correct result