結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,444 KB
testcase_01 AC 19 ms
8,612 KB
testcase_02 AC 19 ms
8,612 KB
testcase_03 AC 240 ms
47,360 KB
testcase_04 AC 235 ms
46,792 KB
testcase_05 AC 240 ms
46,860 KB
testcase_06 AC 242 ms
46,880 KB
testcase_07 AC 240 ms
46,868 KB
testcase_08 AC 238 ms
46,700 KB
testcase_09 AC 244 ms
46,860 KB
testcase_10 AC 241 ms
46,904 KB
testcase_11 AC 240 ms
46,864 KB
testcase_12 AC 239 ms
46,844 KB
testcase_13 AC 204 ms
30,432 KB
testcase_14 AC 159 ms
18,052 KB
testcase_15 AC 19 ms
8,528 KB
testcase_16 AC 20 ms
8,628 KB
testcase_17 AC 20 ms
8,628 KB
testcase_18 AC 19 ms
8,576 KB
testcase_19 AC 20 ms
8,600 KB
testcase_20 AC 128 ms
27,408 KB
testcase_21 AC 140 ms
28,252 KB
testcase_22 AC 103 ms
21,104 KB
testcase_23 AC 128 ms
27,804 KB
testcase_24 AC 230 ms
46,308 KB
testcase_25 AC 99 ms
20,852 KB
testcase_26 AC 150 ms
28,780 KB
testcase_27 AC 72 ms
18,384 KB
testcase_28 AC 216 ms
45,632 KB
testcase_29 AC 157 ms
29,104 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={}
    dp[0]=1
    for i in range(le):
        dp[i+1]=dp[i]+dp[i]-(dp[prev[lst[i]]] if lst[i] in prev else 0)
        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