题解 | #子数组异或和为0的最多划分#
子数组异或和为0的最多划分
http://www.nowcoder.com/practice/77e9828bbe3c4d4a9e0d49cc7537bb6d
n = int(input())
nums = list(map(int, input().split()))
dp = [0] * n
before = {0: -1}
before[nums[0]] = 0
dp[0] = 0 if nums[0] != 0 else 1
eor = nums[0]
for i in range(1, n):
eor ^= nums[i]
if eor in before:
index = before[eor]
if index == -1:
dp[i] = 1
else:
dp[i] = dp[index] + 1
before[eor] = i
dp[i] = max(dp[i - 1], dp[i])
print(dp[-1])