結果

問題 No.1493 隣接xor
ユーザー ygd.ygd.
提出日時 2021-05-05 01:18:05
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 133,344 KB
最終ジャッジ日時 2023-10-01 03:29:40
合計ジャッジ時間 8,087 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,560 KB
testcase_01 AC 71 ms
71,076 KB
testcase_02 AC 73 ms
71,244 KB
testcase_03 AC 175 ms
133,128 KB
testcase_04 AC 176 ms
133,184 KB
testcase_05 AC 178 ms
133,204 KB
testcase_06 AC 173 ms
133,020 KB
testcase_07 AC 172 ms
133,292 KB
testcase_08 AC 171 ms
133,156 KB
testcase_09 AC 171 ms
132,960 KB
testcase_10 AC 177 ms
133,304 KB
testcase_11 AC 175 ms
133,204 KB
testcase_12 AC 175 ms
133,344 KB
testcase_13 AC 134 ms
101,772 KB
testcase_14 AC 114 ms
106,156 KB
testcase_15 AC 74 ms
71,224 KB
testcase_16 AC 72 ms
71,556 KB
testcase_17 AC 72 ms
71,316 KB
testcase_18 AC 77 ms
71,356 KB
testcase_19 AC 73 ms
71,392 KB
testcase_20 AC 125 ms
110,480 KB
testcase_21 AC 132 ms
112,928 KB
testcase_22 AC 113 ms
102,796 KB
testcase_23 AC 124 ms
110,796 KB
testcase_24 AC 171 ms
132,572 KB
testcase_25 AC 110 ms
99,876 KB
testcase_26 AC 131 ms
107,172 KB
testcase_27 AC 103 ms
92,260 KB
testcase_28 AC 163 ms
126,932 KB
testcase_29 AC 130 ms
103,088 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