#P9533. [YsOI2023] 区间翻转区间异或和
[YsOI2023] 区间翻转区间异或和
Background
A data structure problem for Ysuperman template testdata.
The name “符卡 (Fuka)” can be a person’s name or a team name.
Problem Description
Fuka has an integer array of length . Fuka says an interval is a “spooky interval” if and only if , that is, the XOR of all numbers in this interval is exactly .
Fuka has special magic that can reverse any spooky interval. Specifically, if interval is a spooky interval, then Fuka can use magic on it, and the whole array becomes $a_1,a_2,\dots,a_{l-1},a_r,a_{r-1},\dots,a_l,a_{r+1},a_{r+2}\dots,a_n$.
Now Fuka can use magic any number of times. She wants the final array to have as many spooky intervals as possible. Can you tell her what the maximum possible number of spooky intervals is?
Input Format
The first line contains a positive integer , the length of the array.
The second line contains non-negative integers , representing the entire array.
Output Format
Output one line with one integer, the maximum possible number of spooky intervals after Fuka uses magic any number of times.
3
1 1 1
2
4
3 1 2 3
2
Hint
Explanation for Sample 1
No matter how many times Fuka uses magic, the array is always , so using magic or not makes no difference. The spooky intervals are always exactly two: and .
Explanation for Sample 2
One possible way to use the magic is given here.
Choose the spooky interval and use magic. The new array is . This array has two spooky intervals: and .
It can be proven that the answer cannot exceed .
Constraints
For the first of the data, .
For the first of the data, .
Another of the data guarantees that all are equal.
Another of the data guarantees that can take only two possible values.
Another of the data guarantees that .
For of the data, and .
Easter Egg
The name “spooky interval” is actually a pun on “zero XOR interval.”
Translated by ChatGPT 5