結果

問題 No.1863 Xor Sum 2...?
ユーザー rin204rin204
提出日時 2022-03-20 14:24:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 103,040 KB
最終ジャッジ日時 2024-04-16 07:02:59
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,584 KB
testcase_01 AC 42 ms
51,768 KB
testcase_02 AC 45 ms
51,712 KB
testcase_03 AC 45 ms
52,096 KB
testcase_04 AC 42 ms
51,840 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 97 ms
91,008 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 102 ms
91,008 KB
testcase_16 WA -
testcase_17 AC 90 ms
86,400 KB
testcase_18 WA -
testcase_19 AC 86 ms
82,560 KB
testcase_20 AC 99 ms
93,824 KB
testcase_21 WA -
testcase_22 AC 85 ms
80,896 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 127 ms
103,040 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 119 ms
102,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
A_l + ... + A_r が二進数で繰り上がりなし
B_l ^ ... ^ B_r が0

ならOK
"""
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
z = o = 0
tot = 0
Z = [0]
O = [0]
zo = [0]
for b in B:
    tot ^= b
    if tot == 0:
        z += 1
    else:
        o += 1
    Z.append(z)
    O.append(o)
    zo.append(tot)

ans = B.count(0)
bit = 0
l = 0
for r, a in enumerate(A, 1):
    while bit & a != 0:
        bit ^= A[l]
        l += 1
    bit ^= a
    if zo[r] == 0:
        ans += Z[r] - Z[l] - 1
    else:
        ans += O[r] - O[l] - 1
print(ans)


0