結果

問題 No.1863 Xor Sum 2...?
ユーザー rlangevinrlangevin
提出日時 2023-04-05 12:35:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 101,708 KB
最終ジャッジ日時 2024-04-09 22:39:56
合計ジャッジ時間 4,008 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,708 KB
testcase_01 AC 43 ms
54,252 KB
testcase_02 AC 40 ms
54,784 KB
testcase_03 AC 39 ms
55,376 KB
testcase_04 AC 41 ms
54,688 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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 #

from collections import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
D = [0] * (N + 1)
for i in range(N):
    D[i + 1] = D[i] ^ B[i]
Bc = [[0] * (N + 1) for i in range(2)]
for i in range(N):
    Bc[0][i + 1] = Bc[0][i] + 1 - D[i]
    Bc[1][i + 1] = Bc[1][i] + D[i]

Q = deque()
s, x = 0, 0
ans = 0
for i in range(N):
    Q.append(A[i])
    s += A[i]
    x ^= A[i]
    while s != x:
        v = Q.popleft()
        s -= v
        x ^= v
    pre = i - len(Q)
    ans += Bc[B[i]][i + 1] - Bc[B[i]][pre + 1]

print(ans)
0