My issue
What am I missing here?
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int tcase;
long n, k;
string s, t;
cin >> tcase;
while (tcase--) {
cin >> n >> k;
cin >> s >> t;
long match_count = 0, unmatch_count = 0, one_s = 0, one_t = 0;
for (long i = 0; i < n; i++) {
if (s[i] == '1') one_s++;
if (t[i] == '1') one_t++;
if (s[i] == t[i]) match_count++;
else unmatch_count++;
}
unmatch_count /= 2;
if (one_t != one_s) cout << "NO" << endl;
else if (unmatch_count > k) cout << "NO" << endl;
else if ((n == 2) && (unmatch_count % 2 == 0) && k % 2 == 0) cout << "YES" << endl;
else if ((n == 2) && (unmatch_count % 2 == 1) && k % 2 == 1) cout << "YES" << endl;
else if ((n == 2) && (unmatch_count % 2 + k % 2) % 2 == 1) cout << "NO" << endl;
else if (unmatch_count <= k) cout << "YES" << endl;
else if (s == t) cout << "NO" << endl;
else cout << "YES" << endl;
}
}
Problem Link: Binary Conversion Practice Coding Problem