luogu#P9595. 「Daily OI Round 1」Xor
「Daily OI Round 1」Xor
Problem Description
Given a sequence of length , there are queries. In each query, a positive integer is given, and the following operations are performed in order:
- XOR every number in the sequence with .
- Find the longest interval ( are non-negative integers) such that every integer in the interval appears in the sequence. The length of the interval is defined as .
Note that after each query, the sequence is modified.
Some clarifications:
- “Interval” refers to an interval of integers. For example, the integers in interval are , and this is unrelated to the sequence.
- “Sequence” refers to the modified sequence after applying the current query, and does not include any previous versions of the sequence.
Input Format
The first line contains two positive integers , representing the sequence length and the number of queries.
The second line contains positive integers , representing the initial sequence.
The next lines each contain one positive integer , representing a query.
Output Format
Output lines, one integer per line, representing the answer to each query.
5 2
1 2 3 4 5
1
1
4
5
10 10
5 9 8 3 5 7 10 19 5 24
10
56
19
14
18
53
52
57
96
1000
2
2
2
4
2
3
3
2
2
2
Hint
Sample Explanation
For the first sample, the initial sequence is . In the first query, , so after XOR the sequence becomes . Every integer in the interval appears in this sequence. This is the largest interval that satisfies the condition, so the answer is .
Constraints
This problem uses bundled testdata.
| Score | ||||
|---|---|---|---|---|
For all data, it is guaranteed that .
Translated by ChatGPT 5