結果

問題 No.1493 隣接xor
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-05-01 09:57:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 145,224 KB
最終ジャッジ日時 2023-09-26 22:35:20
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,716 KB
testcase_01 AC 92 ms
71,408 KB
testcase_02 AC 94 ms
71,916 KB
testcase_03 AC 233 ms
145,092 KB
testcase_04 AC 196 ms
145,120 KB
testcase_05 AC 195 ms
145,128 KB
testcase_06 AC 196 ms
145,212 KB
testcase_07 AC 200 ms
145,224 KB
testcase_08 AC 201 ms
145,124 KB
testcase_09 AC 200 ms
144,996 KB
testcase_10 AC 198 ms
144,864 KB
testcase_11 AC 198 ms
145,000 KB
testcase_12 AC 200 ms
145,196 KB
testcase_13 AC 151 ms
114,356 KB
testcase_14 AC 138 ms
109,152 KB
testcase_15 AC 94 ms
71,604 KB
testcase_16 AC 93 ms
71,692 KB
testcase_17 AC 92 ms
71,592 KB
testcase_18 AC 94 ms
71,712 KB
testcase_19 AC 91 ms
71,700 KB
testcase_20 AC 147 ms
112,336 KB
testcase_21 AC 156 ms
117,360 KB
testcase_22 AC 137 ms
104,756 KB
testcase_23 AC 148 ms
112,568 KB
testcase_24 AC 194 ms
144,692 KB
testcase_25 AC 134 ms
101,896 KB
testcase_26 AC 157 ms
117,736 KB
testcase_27 AC 125 ms
93,688 KB
testcase_28 AC 182 ms
137,548 KB
testcase_29 AC 161 ms
117,964 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[:n-1],2):
    now ^= a
    dp[i] = dp[i-1]*2 - dp[dic[now]]
    dp[i] %= mod
    dic[now] = i-1
print(dp[n])
0