結果

問題 No.1863 Xor Sum 2...?
ユーザー puznekopuzneko
提出日時 2022-04-08 00:21:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 1,166 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 117,216 KB
最終ジャッジ日時 2023-08-18 19:11:59
合計ジャッジ時間 9,191 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,336 KB
testcase_01 AC 71 ms
71,080 KB
testcase_02 AC 71 ms
71,160 KB
testcase_03 AC 72 ms
71,072 KB
testcase_04 AC 70 ms
71,360 KB
testcase_05 AC 124 ms
81,252 KB
testcase_06 AC 113 ms
79,948 KB
testcase_07 AC 153 ms
88,284 KB
testcase_08 AC 151 ms
88,220 KB
testcase_09 AC 235 ms
106,340 KB
testcase_10 AC 217 ms
104,848 KB
testcase_11 AC 168 ms
92,672 KB
testcase_12 AC 151 ms
87,856 KB
testcase_13 AC 197 ms
98,868 KB
testcase_14 AC 229 ms
104,376 KB
testcase_15 AC 201 ms
97,048 KB
testcase_16 AC 203 ms
99,488 KB
testcase_17 AC 154 ms
89,028 KB
testcase_18 AC 122 ms
80,584 KB
testcase_19 AC 148 ms
87,296 KB
testcase_20 AC 176 ms
94,172 KB
testcase_21 AC 212 ms
101,612 KB
testcase_22 AC 142 ms
85,964 KB
testcase_23 AC 254 ms
109,184 KB
testcase_24 AC 257 ms
110,548 KB
testcase_25 AC 263 ms
116,868 KB
testcase_26 AC 264 ms
117,040 KB
testcase_27 AC 273 ms
116,872 KB
testcase_28 AC 272 ms
116,876 KB
testcase_29 AC 260 ms
116,992 KB
testcase_30 AC 262 ms
117,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
b = [int(x) for x in stdin.readline().rstrip().split()]

bitruiseki = [[0 for i in range(30)] for j in range(n+1)]
for i in range(n):
    val = a[i]
    for j in range(30):
        if val & 1:
            bitruiseki[i+1][j] = bitruiseki[i][j] + 1
        else:
            bitruiseki[i+1][j] = bitruiseki[i][j]
        val = val >> 1

bxor = [0 for i in range(n+1)]
for i in range(n):
    bxor[i+1] = bxor[i] ^ b[i]

bxornum = [0 for i in range(n+1)]
for i in range(n):
    bxornum[i+1] = bxornum[i] + bxor[i]

left = 1
ans = 0
for i in range(1,n+1):
    check = False
    for j in range(30):
        if bitruiseki[i][j] - bitruiseki[left-1][j] >= 2:
            check = True
            break
    while check:
        left += 1
        check = False
        for j in range(30):
            if bitruiseki[i][j] - bitruiseki[left-1][j] >= 2:
                check = True
                break
    if bxor[i] == 1:
        ans += bxornum[i] - bxornum[left-1]
    else:
        ans += i - left + 1 - (bxornum[i] - bxornum[left-1])

print("{}".format(ans))
0