結果

問題 No.1493 隣接xor
ユーザー penguinmanpenguinman
提出日時 2021-04-25 02:33:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 133,224 KB
最終ジャッジ日時 2023-09-17 13:59:23
合計ジャッジ時間 5,820 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,324 KB
testcase_01 AC 75 ms
71,216 KB
testcase_02 AC 74 ms
71,196 KB
testcase_03 AC 179 ms
132,988 KB
testcase_04 AC 179 ms
133,076 KB
testcase_05 AC 176 ms
132,928 KB
testcase_06 AC 177 ms
132,760 KB
testcase_07 AC 179 ms
132,860 KB
testcase_08 AC 183 ms
132,868 KB
testcase_09 AC 179 ms
132,920 KB
testcase_10 AC 177 ms
133,104 KB
testcase_11 AC 178 ms
132,988 KB
testcase_12 AC 180 ms
133,224 KB
testcase_13 AC 141 ms
101,544 KB
testcase_14 AC 119 ms
106,084 KB
testcase_15 AC 74 ms
71,116 KB
testcase_16 AC 76 ms
71,436 KB
testcase_17 AC 74 ms
71,172 KB
testcase_18 AC 74 ms
71,292 KB
testcase_19 AC 76 ms
71,236 KB
testcase_20 AC 125 ms
110,276 KB
testcase_21 AC 133 ms
111,168 KB
testcase_22 AC 116 ms
102,824 KB
testcase_23 AC 126 ms
110,628 KB
testcase_24 AC 176 ms
132,628 KB
testcase_25 AC 115 ms
100,036 KB
testcase_26 AC 136 ms
106,236 KB
testcase_27 AC 102 ms
91,980 KB
testcase_28 AC 169 ms
126,960 KB
testcase_29 AC 132 ms
101,788 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