結果

問題 No.1493 隣接xor
ユーザー AEnAEn
提出日時 2023-09-30 16:42:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 149,804 KB
最終ジャッジ日時 2023-09-30 16:42:13
合計ジャッジ時間 9,370 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,620 KB
testcase_01 AC 99 ms
71,804 KB
testcase_02 AC 93 ms
71,656 KB
testcase_03 AC 263 ms
149,684 KB
testcase_04 AC 201 ms
149,648 KB
testcase_05 AC 231 ms
149,748 KB
testcase_06 AC 208 ms
149,332 KB
testcase_07 AC 199 ms
149,368 KB
testcase_08 AC 201 ms
149,744 KB
testcase_09 AC 201 ms
149,576 KB
testcase_10 AC 228 ms
149,588 KB
testcase_11 AC 201 ms
149,804 KB
testcase_12 AC 201 ms
149,756 KB
testcase_13 AC 151 ms
115,760 KB
testcase_14 AC 138 ms
110,364 KB
testcase_15 AC 93 ms
71,784 KB
testcase_16 AC 94 ms
71,484 KB
testcase_17 AC 117 ms
71,624 KB
testcase_18 AC 118 ms
71,844 KB
testcase_19 AC 98 ms
71,808 KB
testcase_20 AC 149 ms
113,200 KB
testcase_21 AC 154 ms
117,868 KB
testcase_22 AC 136 ms
105,320 KB
testcase_23 AC 148 ms
113,520 KB
testcase_24 AC 193 ms
145,868 KB
testcase_25 AC 135 ms
102,328 KB
testcase_26 AC 172 ms
118,556 KB
testcase_27 AC 123 ms
93,924 KB
testcase_28 AC 185 ms
138,904 KB
testcase_29 AC 157 ms
118,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N = int(input())
A = [0]+list(map(int, input().split()))

d = defaultdict(int)
xor = 0
B = [0]*(N+1)
for i in range(N+1):
    xor ^= A[i]
    B[i] = d[xor]
    d[xor] = i

dp = [0]*(N+1)
mod = 10**9+7
dp[1] = 1
for i in range(1,N):
    dp[i+1] = (2*dp[i]-dp[B[i]])%mod
print(dp[-1])
0