結果

問題 No.1493 隣接xor
ユーザー vwxyzvwxyz
提出日時 2023-02-16 10:51:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 47,448 KB
最終ジャッジ日時 2023-09-25 16:04:30
合計ジャッジ時間 9,935 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,508 KB
testcase_01 AC 19 ms
8,456 KB
testcase_02 AC 18 ms
8,544 KB
testcase_03 AC 287 ms
46,736 KB
testcase_04 AC 283 ms
47,368 KB
testcase_05 AC 283 ms
47,432 KB
testcase_06 AC 280 ms
46,788 KB
testcase_07 AC 287 ms
47,364 KB
testcase_08 AC 281 ms
46,708 KB
testcase_09 AC 287 ms
47,436 KB
testcase_10 AC 299 ms
46,808 KB
testcase_11 AC 283 ms
46,852 KB
testcase_12 AC 287 ms
47,448 KB
testcase_13 AC 212 ms
30,344 KB
testcase_14 AC 169 ms
18,084 KB
testcase_15 AC 19 ms
8,520 KB
testcase_16 AC 19 ms
8,640 KB
testcase_17 AC 19 ms
8,484 KB
testcase_18 AC 18 ms
8,472 KB
testcase_19 AC 18 ms
8,468 KB
testcase_20 AC 151 ms
27,544 KB
testcase_21 AC 169 ms
28,288 KB
testcase_22 AC 123 ms
21,112 KB
testcase_23 AC 155 ms
27,744 KB
testcase_24 AC 279 ms
46,400 KB
testcase_25 AC 118 ms
20,792 KB
testcase_26 AC 180 ms
28,748 KB
testcase_27 AC 84 ms
18,420 KB
testcase_28 AC 259 ms
45,656 KB
testcase_29 AC 181 ms
29,080 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