Replies: 1 comment
-
|
公式解説に実装例が載ってないので、考察含めて書いておきます。E問題の部分問題ですが、C問題のみを解く解法です。
が成り立つ必要がある。 つまり、最初のビット 元の
である。 したがって、最初のビット #include <bits/stdc++.h>
using namespace std;
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
// ======================================== //
int main()
{
int N, M;
cin >> N >> M;
vector<int> A(N), B(N - 1);
rep(i, 0, N) cin >> A[i];
rep(i, 0, N - 1) cin >> B[i];
auto calc = [&](int bit) -> int {
int res = 0;
int now = bit;
rep(i, 0, N) {
if (now != A[i]) {
res++;
}
if (i < N - 1) {
now ^= B[i];
}
}
return res;
};
cout << min(calc(0), calc(1)) << endl;
return 0;
}https://atcoder.jp/contests/abc467/submissions/77592020 ブログにも書きました。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
問題の感想や気づきを投稿・共有するスペースです
Beta Was this translation helpful? Give feedback.
All reactions