結果

問題 No.1863 Xor Sum 2...?
ユーザー ruthenruthen
提出日時 2022-03-04 22:41:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,229 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 166,660 KB
実行使用メモリ 4,404 KB
最終ジャッジ日時 2023-09-26 01:50:28
合計ジャッジ時間 3,661 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 7 ms
4,384 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 16 ms
4,380 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 19 ms
4,380 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 20 ms
4,380 KB
testcase_26 AC 20 ms
4,404 KB
testcase_27 AC 20 ms
4,384 KB
testcase_28 AC 21 ms
4,404 KB
testcase_29 AC 20 ms
4,384 KB
testcase_30 AC 20 ms
4,404 KB
権限があれば一括ダウンロードができます

ソースコード

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];
    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;
}
0