結果

問題 No.1493 隣接xor
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-05-01 09:58:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 145,272 KB
最終ジャッジ日時 2023-09-26 22:39:14
合計ジャッジ時間 6,986 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,856 KB
testcase_01 AC 94 ms
71,676 KB
testcase_02 AC 95 ms
71,944 KB
testcase_03 AC 199 ms
145,152 KB
testcase_04 AC 198 ms
144,940 KB
testcase_05 AC 197 ms
145,008 KB
testcase_06 AC 196 ms
144,984 KB
testcase_07 AC 197 ms
144,956 KB
testcase_08 AC 196 ms
145,140 KB
testcase_09 AC 198 ms
145,080 KB
testcase_10 AC 198 ms
145,272 KB
testcase_11 AC 200 ms
145,000 KB
testcase_12 AC 198 ms
145,184 KB
testcase_13 AC 155 ms
114,392 KB
testcase_14 AC 142 ms
108,716 KB
testcase_15 AC 96 ms
71,692 KB
testcase_16 AC 97 ms
71,612 KB
testcase_17 AC 95 ms
71,664 KB
testcase_18 AC 96 ms
71,424 KB
testcase_19 AC 97 ms
71,852 KB
testcase_20 AC 152 ms
112,536 KB
testcase_21 AC 160 ms
117,092 KB
testcase_22 AC 142 ms
104,732 KB
testcase_23 AC 154 ms
112,696 KB
testcase_24 AC 199 ms
144,380 KB
testcase_25 AC 140 ms
101,708 KB
testcase_26 AC 159 ms
117,504 KB
testcase_27 AC 126 ms
93,872 KB
testcase_28 AC 189 ms
137,536 KB
testcase_29 AC 162 ms
117,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

dic = defaultdict(int)
dp = [0]*(n+1)
dp[1] = 1
now = 0
for i,a in enumerate(A[:-1],1):
    now ^= a
    dp[i+1] = dp[i]*2 - dp[dic[now]]
    dp[i+1] %= mod
    dic[now] = i
print(dp[n])
0