結果
| 問題 |
No.1863 Xor Sum 2...?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-04 22:41:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 1,229 bytes |
| コンパイル時間 | 1,689 ms |
| コンパイル使用メモリ | 168,628 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 21:13:58 |
| 合計ジャッジ時間 | 3,068 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N;
cin >> N;
V<int> A(N), B(N);
rep(i, N) cin >> A[i];
rep(i, N) cin >> B[i];
V<int> C(N + 1, 0);
rep(i, N) C[i + 1] = C[i] ^ B[i];
show(C);
int r = 0, c0 = 1, c1 = 0;
ll s = 0, xs = 0, ans = 0;
for (int l = 0; l < N; l++) {
// hoge
while (r < N && (s + A[r]) == (xs ^ A[r])) {
s += A[r];
xs ^= A[r];
if (C[r + 1] == 1) {
c1++;
} else {
c0++;
}
r++;
}
show(l, r, s, xs, c0, c1);
// ans += r - l - c % 2;
ans += r - l;
show("1", ans);
if (C[l] == 0) {
ans -= c1;
} else {
ans -= c0;
}
show("2", ans);
s -= A[l];
xs ^= A[l];
if (C[l] == 1) {
c1--;
} else {
c0--;
}
}
cout << ans << '\n';
return 0;
}