結果

問題 No.1493 隣接xor
ユーザー googol_S0googol_S0
提出日時 2021-04-30 22:03:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 138,028 KB
最終ジャッジ日時 2023-09-26 06:07:43
合計ジャッジ時間 6,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,304 KB
testcase_01 AC 71 ms
71,304 KB
testcase_02 AC 73 ms
71,296 KB
testcase_03 AC 198 ms
137,720 KB
testcase_04 AC 189 ms
137,812 KB
testcase_05 AC 189 ms
137,736 KB
testcase_06 AC 187 ms
137,976 KB
testcase_07 AC 192 ms
137,984 KB
testcase_08 AC 199 ms
137,828 KB
testcase_09 AC 180 ms
138,028 KB
testcase_10 AC 183 ms
137,820 KB
testcase_11 AC 185 ms
137,736 KB
testcase_12 AC 182 ms
137,860 KB
testcase_13 AC 140 ms
108,480 KB
testcase_14 AC 126 ms
109,632 KB
testcase_15 AC 73 ms
71,084 KB
testcase_16 AC 71 ms
71,092 KB
testcase_17 AC 69 ms
71,460 KB
testcase_18 AC 71 ms
71,180 KB
testcase_19 AC 69 ms
71,164 KB
testcase_20 AC 131 ms
114,688 KB
testcase_21 AC 135 ms
106,624 KB
testcase_22 AC 119 ms
104,828 KB
testcase_23 AC 132 ms
112,212 KB
testcase_24 AC 182 ms
137,192 KB
testcase_25 AC 125 ms
101,676 KB
testcase_26 AC 138 ms
100,100 KB
testcase_27 AC 105 ms
93,228 KB
testcase_28 AC 173 ms
131,324 KB
testcase_29 AC 138 ms
101,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
C=[0]*(N+1)
F=[0]*(N+1)
F[0]=1
F[1]=1
for i in range(N):
  if i:
    F[i+1]=F[i]&(A[i]==A[i-1])
  C[i+1]=C[i]^A[i]
D=dict()
D[0]=0
B=[0]*(N+1)
for i in range(N):
  B[i+1]=D.get(C[i+1],0)
  D[C[i+1]]=i+1
mod=10**9+7
DP=[0]*(N+2)
DP[1]=1
for i in range(N):
  DP[i+2]=(DP[i+1]+DP[i+1]-DP[B[i+1]]+min(B[i+1],1)*F[i+1])%mod
print((DP[N+1]-DP[N])%mod)
0