結果
| 問題 |
No.1493 隣接xor
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:14:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 535 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 81,972 KB |
| 実行使用メモリ | 132,296 KB |
| 最終ジャッジ日時 | 2025-06-12 19:14:59 |
| 合計ジャッジ時間 | 5,183 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
MOD = 10**9 + 7
n = int(input())
A = list(map(int, input().split()))
prefix = [0] * (n + 1)
for i in range(n):
prefix[i+1] = prefix[i] ^ A[i]
target = prefix[n]
from collections import defaultdict
last = defaultdict(int)
last[0] = 1 # Initial state: the subsequence [0]
total = 1 # Sum of all values in 'last', initially 1
for i in range(1, n + 1):
s = prefix[i]
new_count = (total - last[s]) % MOD
total = (total + new_count) % MOD
last[s] = (last[s] + new_count) % MOD
print(last.get(target, 0) % MOD)
gew1fw