結果

問題 No.1493 隣接xor
ユーザー vwxyzvwxyz
提出日時 2023-02-16 11:58:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 47,452 KB
最終ジャッジ日時 2023-09-25 16:57:41
合計ジャッジ時間 6,665 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,512 KB
testcase_01 AC 19 ms
8,648 KB
testcase_02 AC 19 ms
8,584 KB
testcase_03 AC 278 ms
47,452 KB
testcase_04 AC 273 ms
47,304 KB
testcase_05 AC 279 ms
46,728 KB
testcase_06 AC 273 ms
47,380 KB
testcase_07 AC 277 ms
46,896 KB
testcase_08 AC 271 ms
47,368 KB
testcase_09 AC 274 ms
47,424 KB
testcase_10 AC 271 ms
47,420 KB
testcase_11 AC 271 ms
46,868 KB
testcase_12 AC 270 ms
47,416 KB
testcase_13 AC 197 ms
30,364 KB
testcase_14 AC 155 ms
18,100 KB
testcase_15 AC 18 ms
8,628 KB
testcase_16 AC 19 ms
8,520 KB
testcase_17 AC 19 ms
8,588 KB
testcase_18 AC 18 ms
8,572 KB
testcase_19 AC 18 ms
8,524 KB
testcase_20 AC 148 ms
27,508 KB
testcase_21 AC 164 ms
28,508 KB
testcase_22 AC 118 ms
21,008 KB
testcase_23 AC 148 ms
27,828 KB
testcase_24 AC 269 ms
46,452 KB
testcase_25 AC 116 ms
20,824 KB
testcase_26 AC 179 ms
28,808 KB
testcase_27 AC 82 ms
18,324 KB
testcase_28 AC 246 ms
45,668 KB
testcase_29 AC 181 ms
29,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline
from collections import defaultdict

N=int(readline())
A=list(map(int,readline().split()))
for i in range(1,N-1):
    A[i]^=A[i-1]
A.pop()
def Subsequence_Count(lst,mod=0):
    le=len(lst)
    dp=[0]*(le+1)
    prev=defaultdict(lambda:-1)
    dp[0]=1
    for i in range(le):
        dp[i+1]=dp[i]+dp[i]-dp[prev[lst[i]]]
        if mod:
            dp[i+1]%=mod
        prev[lst[i]]=i
    return dp[le]
mod=10**9+7
ans=Subsequence_Count(A,mod)
print(ans)
0