Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fei0319 committed Jan 20, 2024
2 parents be99d2f + 4306fd1 commit 9dd82e1
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions contest/cf1906/B.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,46 @@
using ll = long long int;

int f(std::vector<int> a) {
int res = 0, n = a.size();
for (int i = 0; i < n; ++i) {
if (!a[i]) continue;
if (i == res) {
res += 1;
continue;
}
if (i + 1 < n && a[i + 1]) {
res += 2;
a[i] = 0;
a[i + 1] = 0;
} else {
res += 2;
if (i + 1 < n)
a[i + 1] ^= 1;
}
}
return res;
int res = 0, n = a.size();
for (int i = 0; i < n; ++i) {
if (!a[i])
continue;
if (i == res) {
res += 1;
continue;
}
if (i + 1 < n && a[i + 1]) {
res += 2;
a[i] = 0;
a[i + 1] = 0;
} else {
res += 2;
if (i + 1 < n)
a[i + 1] ^= 1;
}
}
return res;
}

void read(std::vector<int> &a) {
std::string s;
std::cin >> s;
a.resize(s.size());
for (int i = 0; i < (int)s.size(); ++i) {
a[i] = (s[i] == '1');
}
std::string s;
std::cin >> s;
a.resize(s.size());
for (int i = 0; i < (int)s.size(); ++i) {
a[i] = (s[i] == '1');
}
}

void solve(void) {
int n;
std::cin >> n;
std::vector<int> a(n), b(n);
read(a), read(b);
if ((f(a) + 1) / 2 == (f(b) + 1) / 2) {
std::cout << "YES\n";
} else {
std::cout << "NO\n";
}
int n;
std::cin >> n;
std::vector<int> a(n), b(n);
read(a), read(b);
if ((f(a) + 1) / 2 == (f(b) + 1) / 2) {
std::cout << "YES\n";
} else {
std::cout << "NO\n";
}
}

int main(int argc, char *argv[]) {
Expand Down

0 comments on commit 9dd82e1

Please sign in to comment.