結果

問題 No.1863 Xor Sum 2...?
ユーザー ruthenruthen
提出日時 2022-03-04 22:25:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 166,428 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-26 01:32:29
合計ジャッジ時間 3,517 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 % 2;
        }
        s -= A[l];
        xs ^= A[l];
        c -= B[l];
    }
    cout << ans << '\n';
    return 0;
}
0