結果

問題 No.1863 Xor Sum 2...?
ユーザー titiatitia
提出日時 2022-03-07 00:20:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 19,396 KB
最終ジャッジ日時 2023-09-28 16:17:57
合計ジャッジ時間 7,888 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 17 ms
7,840 KB
testcase_02 AC 17 ms
7,856 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 15 ms
7,820 KB
testcase_05 AC 58 ms
10,772 KB
testcase_06 AC 33 ms
9,320 KB
testcase_07 AC 97 ms
12,320 KB
testcase_08 AC 93 ms
12,852 KB
testcase_09 AC 215 ms
17,228 KB
testcase_10 AC 194 ms
17,996 KB
testcase_11 AC 114 ms
14,480 KB
testcase_12 AC 90 ms
12,336 KB
testcase_13 AC 163 ms
16,100 KB
testcase_14 AC 202 ms
17,660 KB
testcase_15 AC 155 ms
15,724 KB
testcase_16 AC 169 ms
15,276 KB
testcase_17 AC 99 ms
13,836 KB
testcase_18 AC 51 ms
10,480 KB
testcase_19 AC 79 ms
12,184 KB
testcase_20 AC 131 ms
14,308 KB
testcase_21 AC 180 ms
16,252 KB
testcase_22 AC 73 ms
11,520 KB
testcase_23 AC 243 ms
18,332 KB
testcase_24 AC 237 ms
18,880 KB
testcase_25 AC 258 ms
19,240 KB
testcase_26 AC 258 ms
19,376 KB
testcase_27 AC 253 ms
19,372 KB
testcase_28 AC 260 ms
19,396 KB
testcase_29 AC 256 ms
19,260 KB
testcase_30 AC 257 ms
19,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
XOR=[0]
for b in B:
    XOR.append(XOR[-1]^b)

SA=[0]
SB=[0]

for i in range(1,N+1):
    if XOR[i]==0:
        SA.append(SA[-1]+1)
        SB.append(SB[-1])
    else:
        SA.append(SA[-1])
        SB.append(SB[-1]+1)

ANS=0
UA=0
XA=0
ind=0

for i in range(N):
    while True:
        if ind<N and UA+A[ind]==XA^A[ind]:
            UA+=A[ind]
            XA^=A[ind]
            ind+=1
        else:
            break

    #print(i,ind)

    # i から ind-1 まで。

    if XOR[i]==0:
        ANS+=SA[ind]-SA[i]
    else:
        ANS+=SB[ind]-SB[i]

    #print(ANS)

    UA-=A[i]
    XA^=A[i]

print(ANS)
0