結果

問題 No.1493 隣接xor
ユーザー penguinmanpenguinman
提出日時 2021-07-13 07:22:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 54,100 KB
最終ジャッジ日時 2023-09-15 04:41:44
合計ジャッジ時間 7,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,856 KB
testcase_01 AC 16 ms
7,824 KB
testcase_02 AC 16 ms
7,788 KB
testcase_03 AC 340 ms
54,000 KB
testcase_04 AC 326 ms
53,988 KB
testcase_05 AC 332 ms
53,968 KB
testcase_06 AC 334 ms
54,028 KB
testcase_07 AC 331 ms
53,928 KB
testcase_08 AC 331 ms
54,084 KB
testcase_09 AC 331 ms
53,964 KB
testcase_10 AC 336 ms
54,100 KB
testcase_11 AC 330 ms
53,944 KB
testcase_12 AC 334 ms
53,944 KB
testcase_13 AC 338 ms
29,952 KB
testcase_14 AC 277 ms
19,120 KB
testcase_15 AC 16 ms
7,944 KB
testcase_16 AC 16 ms
7,844 KB
testcase_17 AC 16 ms
7,928 KB
testcase_18 AC 16 ms
7,824 KB
testcase_19 AC 16 ms
7,824 KB
testcase_20 AC 175 ms
31,272 KB
testcase_21 AC 196 ms
32,484 KB
testcase_22 AC 139 ms
23,964 KB
testcase_23 AC 181 ms
31,532 KB
testcase_24 AC 326 ms
53,388 KB
testcase_25 AC 135 ms
23,556 KB
testcase_26 AC 205 ms
33,208 KB
testcase_27 AC 93 ms
19,784 KB
testcase_28 AC 295 ms
52,296 KB
testcase_29 AC 217 ms
33,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = int(1e9+7)

N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for i in range(N):
    B[i+1] = A[i]^B[i]

dp = [0]*N
dp[0] = 1
mem = {}

for i in range(1,N):
    dp[i] = dp[i-1]*2
    if B[i] in mem.keys():
        dp[i] -= dp[mem[B[i]]-1]
    dp[i] %= mod
    if dp[i] < 0:
        dp[i] += mod
    mem[B[i]] = i
print(dp[N-1])
0