結果
問題 |
No.1493 隣接xor
|
ユーザー |
![]() |
提出日時 | 2025-07-23 06:39:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 408 ms / 2,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 478 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 56,336 KB |
最終ジャッジ日時 | 2025-07-23 06:39:26 |
合計ジャッジ時間 | 10,518 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) mod=10**9+7 XOR=[0] for a in A: XOR.append(XOR[-1]^a) DP=[0]*len(XOR) DP[0]=1 LAST=dict() for i in range(1,len(XOR)): x=XOR[i] if x in LAST: l=LAST[x] DP[i]=DP[i-1]*2-DP[l-1] else: DP[i]=DP[i-1]*2 DP[i]%=mod LAST[x]=i print(DP[-2])