-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2092B.cpp
More file actions
60 lines (50 loc) · 1 KB
/
Copy path2092B.cpp
File metadata and controls
60 lines (50 loc) · 1 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define umap unordered_map
#define f(i, x, n) for (ll i = x; i < n; i++)
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
optimize();
ll t;
cin >> t;
while(t--) {
ll n;
cin >> n;
string a, b;
cin >> a >> b;
ll a_ones = 0, b_zrs = 0, a_e_ones = 0, a_o_ones = 0, b_e_zrs = 0, b_o_zrs = 0;
f(i, 0, n) {
if (a[i] == '1') {
a_ones++;
if (i&1) {
a_o_ones++;
} else {
a_e_ones++;
}
}
if(b[i] == '0') {
b_zrs++;
if(i&1) {
b_o_zrs++;
} else {
b_e_zrs++;
}
}
}
if (a_ones == 0) {
cout << "YES" << endl;
} else if (b_zrs < a_ones) {
cout << "NO" << endl;
} else {
if (b_o_zrs >= a_e_ones && b_e_zrs >= a_o_ones) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
}