#P10650. Phantom Number
Phantom Number
Phantom Number
Given an integer sequence \(a\) of length \(n\). An integer \(b\) is called a phantom number of the sequence if it satisfies:
\[ (a_1 \oplus b) \le (a_2 \oplus b) \le \dots \le (a_n \oplus b), \]where \(\oplus\) denotes the bitwise XOR operation.
There are \(q\) modifications. In each modification, one element \(a_{u_i}\) is updated to \(k_i\), and each update affects all subsequent queries. You need to determine the minimum phantom number for the initial sequence (before any modifications) and after each modification. If no such number exists, output \(-1\).
inputFormat
The first line contains two integers \(n\) and \(q\) representing the length of the sequence and the number of modifications.
The second line contains \(n\) integers \(a_1, a_2, \dots, a_n\) representing the initial sequence.
Each of the next \(q\) lines contains two integers \(u_i\) and \(k_i\), indicating that \(a_{u_i}\) is changed to \(k_i\).
outputFormat
Output \(q+1\) lines. The first line should contain the minimum phantom number of the original sequence, and each of the following \(q\) lines should contain the minimum phantom number after each modification. If no phantom number exists, output \(-1\) for that case.
sample
3 2
1 2 3
2 1
3 4
0
0
0
</p>