結果

問題 No.1493 隣接xor
ユーザー vwxyzvwxyz
提出日時 2023-02-16 10:51:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 141,416 KB
最終ジャッジ日時 2023-09-25 16:04:40
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,636 KB
testcase_01 AC 95 ms
71,640 KB
testcase_02 AC 94 ms
71,620 KB
testcase_03 AC 204 ms
139,148 KB
testcase_04 AC 204 ms
139,208 KB
testcase_05 AC 204 ms
138,940 KB
testcase_06 AC 213 ms
139,196 KB
testcase_07 AC 202 ms
139,008 KB
testcase_08 AC 205 ms
139,004 KB
testcase_09 AC 206 ms
139,020 KB
testcase_10 AC 204 ms
138,972 KB
testcase_11 AC 205 ms
138,804 KB
testcase_12 AC 205 ms
138,912 KB
testcase_13 AC 158 ms
110,780 KB
testcase_14 AC 145 ms
107,108 KB
testcase_15 AC 97 ms
71,852 KB
testcase_16 AC 96 ms
71,852 KB
testcase_17 AC 94 ms
71,724 KB
testcase_18 AC 95 ms
71,664 KB
testcase_19 AC 95 ms
71,784 KB
testcase_20 AC 154 ms
110,828 KB
testcase_21 AC 159 ms
115,156 KB
testcase_22 AC 146 ms
103,296 KB
testcase_23 AC 154 ms
110,880 KB
testcase_24 AC 198 ms
141,416 KB
testcase_25 AC 143 ms
100,516 KB
testcase_26 AC 160 ms
115,572 KB
testcase_27 AC 128 ms
93,160 KB
testcase_28 AC 185 ms
134,456 KB
testcase_29 AC 162 ms
115,824 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+2)
    prev=defaultdict(lambda:-1)
    dp[1]=1
    for i in range(le):
        dp[i+2]=dp[i+1]+dp[i+1]-dp[prev[lst[i]]+1]
        if mod:
            dp[i+2]%=mod
        prev[lst[i]]=i
    return dp[le+1]
mod=10**9+7
ans=Subsequence_Count(A,mod)
print(ans)
0