結果

問題 No.1493 隣接xor
ユーザー rlangevinrlangevin
提出日時 2024-04-11 08:54:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 82,488 KB
実行使用メモリ 133,716 KB
最終ジャッジ日時 2024-04-11 08:54:59
合計ジャッジ時間 6,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
54,088 KB
testcase_01 AC 39 ms
55,112 KB
testcase_02 AC 42 ms
53,740 KB
testcase_03 AC 168 ms
133,588 KB
testcase_04 AC 154 ms
133,660 KB
testcase_05 AC 149 ms
133,432 KB
testcase_06 AC 149 ms
133,304 KB
testcase_07 AC 146 ms
133,296 KB
testcase_08 AC 158 ms
133,716 KB
testcase_09 AC 158 ms
133,508 KB
testcase_10 AC 146 ms
133,308 KB
testcase_11 AC 152 ms
133,640 KB
testcase_12 AC 146 ms
133,564 KB
testcase_13 AC 107 ms
102,244 KB
testcase_14 AC 90 ms
107,316 KB
testcase_15 AC 39 ms
53,664 KB
testcase_16 AC 39 ms
54,008 KB
testcase_17 AC 37 ms
53,948 KB
testcase_18 AC 38 ms
54,488 KB
testcase_19 AC 37 ms
54,304 KB
testcase_20 AC 102 ms
109,000 KB
testcase_21 AC 110 ms
107,128 KB
testcase_22 AC 86 ms
100,592 KB
testcase_23 AC 98 ms
109,248 KB
testcase_24 AC 134 ms
111,836 KB
testcase_25 AC 80 ms
97,404 KB
testcase_26 AC 103 ms
100,516 KB
testcase_27 AC 68 ms
87,084 KB
testcase_28 AC 132 ms
109,028 KB
testcase_29 AC 105 ms
98,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
Ac = [0] * (N + 1)
for i in range(N):
    Ac[i + 1] = Ac[i] ^ A[i]
    
from collections import *
ind = defaultdict(int)
dp = [0] * (N + 1)
dp[0] = 1
mod = 10 ** 9 + 7
for i in range(1, N):
    dp[i] = (dp[i - 1] * 2 - dp[ind[Ac[i]] - 1]) % mod
    ind[Ac[i]] = i
    
print(dp[N - 1])
0