結果

問題 No.1493 隣接xor
ユーザー penguinmanpenguinman
提出日時 2021-04-25 02:34:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 51,672 KB
最終ジャッジ日時 2023-09-26 01:56:46
合計ジャッジ時間 9,393 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,968 KB
testcase_01 AC 15 ms
7,884 KB
testcase_02 AC 15 ms
7,916 KB
testcase_03 AC 300 ms
51,528 KB
testcase_04 AC 300 ms
51,544 KB
testcase_05 AC 298 ms
51,512 KB
testcase_06 AC 295 ms
51,672 KB
testcase_07 AC 302 ms
51,624 KB
testcase_08 AC 308 ms
51,628 KB
testcase_09 AC 305 ms
51,668 KB
testcase_10 AC 293 ms
51,532 KB
testcase_11 AC 306 ms
51,528 KB
testcase_12 AC 302 ms
51,524 KB
testcase_13 AC 299 ms
29,884 KB
testcase_14 AC 253 ms
17,484 KB
testcase_15 AC 15 ms
7,948 KB
testcase_16 AC 15 ms
7,784 KB
testcase_17 AC 15 ms
7,800 KB
testcase_18 AC 15 ms
7,808 KB
testcase_19 AC 15 ms
7,952 KB
testcase_20 AC 161 ms
29,920 KB
testcase_21 AC 179 ms
30,768 KB
testcase_22 AC 129 ms
23,228 KB
testcase_23 AC 163 ms
30,116 KB
testcase_24 AC 298 ms
51,192 KB
testcase_25 AC 124 ms
22,924 KB
testcase_26 AC 189 ms
32,004 KB
testcase_27 AC 85 ms
19,092 KB
testcase_28 AC 279 ms
50,940 KB
testcase_29 AC 197 ms
32,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
dp = [0]*N
dp[0] = 1
mem = {}
now = 0
mod = int(1e9+7)
for i in range(N-1):
    now ^= A[i]
    dp[i+1] = dp[i]*2
    if now in mem.keys():
        dp[i+1] -= dp[mem[now]]
    dp[i+1] %= mod
    if dp[i+1] < 0:
        dp[i+1] += dp[i+1]
    mem[now] = i
print(dp[N-1])
0