結果

問題 No.1863 Xor Sum 2...?
ユーザー roarisroaris
提出日時 2022-03-05 00:09:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 101,584 KB
最終ジャッジ日時 2023-09-26 04:07:36
合計ジャッジ時間 5,471 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,536 KB
testcase_01 AC 75 ms
71,340 KB
testcase_02 AC 71 ms
71,052 KB
testcase_03 AC 71 ms
71,348 KB
testcase_04 AC 71 ms
71,048 KB
testcase_05 AC 90 ms
78,436 KB
testcase_06 AC 86 ms
76,424 KB
testcase_07 AC 98 ms
84,648 KB
testcase_08 AC 98 ms
84,692 KB
testcase_09 AC 125 ms
99,336 KB
testcase_10 AC 114 ms
96,124 KB
testcase_11 AC 104 ms
90,196 KB
testcase_12 AC 96 ms
84,380 KB
testcase_13 AC 114 ms
95,200 KB
testcase_14 AC 116 ms
96,148 KB
testcase_15 AC 111 ms
95,252 KB
testcase_16 AC 109 ms
95,292 KB
testcase_17 AC 98 ms
86,248 KB
testcase_18 AC 88 ms
76,920 KB
testcase_19 AC 95 ms
82,984 KB
testcase_20 AC 108 ms
92,492 KB
testcase_21 AC 116 ms
98,480 KB
testcase_22 AC 93 ms
81,092 KB
testcase_23 AC 120 ms
98,916 KB
testcase_24 AC 128 ms
101,240 KB
testcase_25 AC 129 ms
101,336 KB
testcase_26 AC 130 ms
101,296 KB
testcase_27 AC 132 ms
101,584 KB
testcase_28 AC 130 ms
101,452 KB
testcase_29 AC 131 ms
101,256 KB
testcase_30 AC 132 ms
101,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
S = 0
X = 0
r = 0
ans = 0
acc = [0]

for Bi in B:
    acc.append(acc[-1]^Bi)

acc_acc = [acc[0]]

for acc_i in acc[1:]:
    acc_acc.append(acc_acc[-1]+acc_i)

ans = 0

for l in range(N):
    while r<N and S+A[r]==X^A[r]:
        S += A[r]
        X ^= A[r]
        r += 1
    
    if acc[l]==0:
        ans += r-l-(acc_acc[r]-acc_acc[l])
    else:
        ans += acc_acc[r]-acc_acc[l]
    
    S -= A[l]
    X ^= A[l]

print(ans)
0