結果

問題 No.1863 Xor Sum 2...?
ユーザー ruthen71
提出日時 2022-03-04 22:22:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 168,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 20:55:08
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
    int r = 0, c = 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];
            c += B[r];
            r++;
        }
        show(l, r, s, xs, c, ans);
        if (B[l] == 0) {
            ans += r - l - c;
        }
        s -= A[l];
        xs ^= A[l];
        c -= B[l];
    }
    cout << ans << '\n';
    return 0;
}
0