#P10650. [ROI 2017] 排序幻觉 (Day 1)
[ROI 2017] 排序幻觉 (Day 1)
Problem Description
Given an integer sequence of length , if an integer satisfies:
$$(a_1 \operatorname{xor} b) \le (a_2 \operatorname{xor} b) \le \dots \le (a_n \operatorname{xor} b)$$then is called a magic number of the sequence .
Next, there are modifications. In each modification, one number is changed to an integer . Each modification affects the queries that follow. You need to find the smallest magic number of the sequence before the first modification and after each modification. In particular, if no magic number exists, output .
Input Format
The first line contains an integer , indicating the length of the sequence.
The second line contains integers, representing the integer sequence .
The third line contains an integer , indicating the number of queries.
The next lines each contain two integers and , meaning that is modified to .
Output Format
Output a total of lines. Each line contains one integer, representing the smallest magic number of the current sequence. If there is no magic number, output .
3
0 1 4
3
2 7
3 3
1 4
0
2
-1
4
Hint
Constraints
| Subtask ID | Score | |||
|---|---|---|---|---|
Translated by ChatGPT 5