結果

問題 No.1863 Xor Sum 2...?
ユーザー hitonanodehitonanode
提出日時 2023-05-10 06:49:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,924 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 23,544 KB
最終ジャッジ日時 2024-06-11 06:32:57
合計ジャッジ時間 32,919 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 384 ms
13,696 KB
testcase_06 AC 174 ms
11,648 KB
testcase_07 AC 641 ms
15,224 KB
testcase_08 AC 614 ms
15,088 KB
testcase_09 AC 1,590 ms
21,104 KB
testcase_10 AC 1,458 ms
20,260 KB
testcase_11 AC 823 ms
16,192 KB
testcase_12 AC 605 ms
14,856 KB
testcase_13 AC 1,182 ms
18,632 KB
testcase_14 AC 1,496 ms
20,352 KB
testcase_15 AC 1,153 ms
18,220 KB
testcase_16 AC 1,197 ms
18,636 KB
testcase_17 AC 663 ms
15,300 KB
testcase_18 AC 294 ms
12,544 KB
testcase_19 AC 546 ms
14,956 KB
testcase_20 AC 929 ms
16,732 KB
testcase_21 AC 1,329 ms
19,372 KB
testcase_22 AC 491 ms
13,920 KB
testcase_23 AC 1,712 ms
22,040 KB
testcase_24 AC 1,829 ms
22,976 KB
testcase_25 AC 1,883 ms
23,480 KB
testcase_26 AC 1,920 ms
23,416 KB
testcase_27 AC 1,924 ms
23,436 KB
testcase_28 AC 1,875 ms
23,544 KB
testcase_29 AC 1,884 ms
23,544 KB
testcase_30 AC 1,868 ms
23,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, A, B)

lasts = [0] * 30

n0 = [0] * (N + 1)
n1 = [0] * (N + 1)

ret = 0

lim = 0

bc = 0

n0[0] = 1

for i, a in enumerate(A):
    bc ^= B[i]
    n0[i + 1] = n0[i]
    n1[i + 1] = n1[i]

    left = lim
    for d in range(30):
        if a & (1 << d):
            lim = max(lim, lasts[d] + 1)
            left = max(left, lasts[d] + 1)
            lasts[d] = i + 1

    if bc:
        ret += n1[i] - (n1[left - 2] if left > 1 else 0)
    else:
        ret += n0[i] - (n0[left - 2] if left > 1 else 0)

    n0[i + 1] += (bc == 0)
    n1[i + 1] += (bc == 1)

print(ret)
0