結果

問題 No.1493 隣接xor
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-08-15 12:35:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 56,664 KB
最終ジャッジ日時 2024-04-16 11:30:22
合計ジャッジ時間 8,358 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,496 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 33 ms
10,624 KB
testcase_03 AC 347 ms
56,536 KB
testcase_04 AC 334 ms
56,528 KB
testcase_05 AC 335 ms
56,532 KB
testcase_06 AC 333 ms
56,532 KB
testcase_07 AC 329 ms
56,444 KB
testcase_08 AC 333 ms
56,408 KB
testcase_09 AC 329 ms
56,532 KB
testcase_10 AC 341 ms
56,664 KB
testcase_11 AC 326 ms
56,532 KB
testcase_12 AC 330 ms
56,540 KB
testcase_13 AC 336 ms
32,364 KB
testcase_14 AC 290 ms
21,556 KB
testcase_15 AC 30 ms
10,624 KB
testcase_16 AC 29 ms
10,496 KB
testcase_17 AC 30 ms
10,624 KB
testcase_18 AC 31 ms
10,624 KB
testcase_19 AC 30 ms
10,624 KB
testcase_20 AC 179 ms
33,664 KB
testcase_21 AC 199 ms
34,888 KB
testcase_22 AC 148 ms
26,356 KB
testcase_23 AC 183 ms
33,836 KB
testcase_24 AC 332 ms
55,828 KB
testcase_25 AC 144 ms
26,256 KB
testcase_26 AC 217 ms
35,532 KB
testcase_27 AC 105 ms
22,064 KB
testcase_28 AC 303 ms
54,680 KB
testcase_29 AC 218 ms
36,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(n):
	b.append(b[-1] ^ a[i])
dp = [0] * n
dp[0] = 1
prev = dict()
for i in range(1, n):
	dp[i] = dp[i - 1] * 2
	if b[i] in prev:
		dp[i] -= dp[prev[b[i]] - 1]
	dp[i] %= mod
	prev[b[i]] = i
print(dp[-1])
0