-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2092b.cpp
More file actions
48 lines (37 loc) · 996 Bytes
/
2092b.cpp
File metadata and controls
48 lines (37 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
int main() {
fastio;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string a,b;
cin >> a;
cin >> b;
long long ones_comp1 = 0, ones_comp2 = 0;
long long b_slots_comp1 = 0, b_slots_comp2 = 0;
for (int i = 0; i < n; i++) {
if (i % 2 == 1) {
// odd index
if (a[i] == '1') ones_comp1++;
if (b[i] == '1') ones_comp2++;
b_slots_comp2++;
} else {
// even index
if (a[i] == '1') ones_comp2++;
if (b[i] == '1') ones_comp1++;
b_slots_comp1++;
}
}
if (ones_comp1 <= b_slots_comp1 &&
ones_comp2 <= b_slots_comp2) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}