結果

問題 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,937 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 23,056 KB
最終ジャッジ日時 2023-12-22 01:57:33
合計ジャッジ時間 33,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 AC 29 ms
9,984 KB
testcase_02 AC 29 ms
9,984 KB
testcase_03 AC 29 ms
9,984 KB
testcase_04 AC 29 ms
9,984 KB
testcase_05 AC 362 ms
12,928 KB
testcase_06 AC 170 ms
11,008 KB
testcase_07 AC 617 ms
14,344 KB
testcase_08 AC 607 ms
14,328 KB
testcase_09 AC 1,564 ms
20,740 KB
testcase_10 AC 1,452 ms
19,888 KB
testcase_11 AC 836 ms
15,560 KB
testcase_12 AC 593 ms
14,236 KB
testcase_13 AC 1,173 ms
18,004 KB
testcase_14 AC 1,458 ms
19,860 KB
testcase_15 AC 1,144 ms
17,460 KB
testcase_16 AC 1,197 ms
18,172 KB
testcase_17 AC 661 ms
14,332 KB
testcase_18 AC 292 ms
11,776 KB
testcase_19 AC 550 ms
14,276 KB
testcase_20 AC 917 ms
16,248 KB
testcase_21 AC 1,324 ms
19,008 KB
testcase_22 AC 481 ms
13,084 KB
testcase_23 AC 1,718 ms
21,680 KB
testcase_24 AC 1,801 ms
22,476 KB
testcase_25 AC 1,931 ms
23,056 KB
testcase_26 AC 1,918 ms
22,672 KB
testcase_27 AC 1,924 ms
23,056 KB
testcase_28 AC 1,920 ms
23,056 KB
testcase_29 AC 1,918 ms
23,056 KB
testcase_30 AC 1,937 ms
22,672 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