#P4425. [HNOI/AHOI2018] 转盘
[HNOI/AHOI2018] 转盘
Description
Xiao G and Xiao H plan to have a dinner, but to keep things simple, the statement is as follows:
There is a turntable with items arranged in a circle (numbered ). The -th item appears at time .
At time , Xiao G can choose any one of the items; denote it by . If at time he chooses item , then at time he can either keep the current item or move to the next item. When equals , the next item is item ; otherwise it is item . At every time (including time ), if the item Xiao G chooses has already appeared, then he will mark it. Xiao H wants to know, under the optimal strategy of choosing items, when can Xiao G mark all items.
However, the appearance times of items will be modified from time to time. We describe this as modifications, each changing the appearance time of one item. After each modification, you must also output the answer for the current state. For some test points, Xiao H also imposes a forced online constraint.
Input Format
The first line contains three non-negative integers , , and , meaning there are items and modifications. The value of is either or ; when , the problem is forced online; otherwise .
The next line contains non-negative integers. The -th number is the appearance time of item .
Each of the next lines contains two non-negative integers and , representing one modification and its query. The modification works as follows:
- If , set the appearance time of item to , i.e., .
- If , first XOR and with LastAns respectively to obtain and , then set . Here LastAns is the result of the previous query; in particular, for the first modification, LastAns is the answer for the initial state.
It is guaranteed that the input is valid.
Output Format
Output one integer on the first line, the answer for the initial state.
Then output lines, each containing one integer, the answer after each modification.
5 3 0
1 2 3 4 5
3 5
5 0
1 4
5
7
6
7
Hint
【Constraints】
::cute-table[]{tuack} | Test point id | | | | | | :-: | :-: | :-: | :-: | :-: | | 1 | | | | | | 2 | | | | ^ | | 3 | | ^ | | ^ | | 4 | | | ^ | ^ | | 5 | | | ^ | ^ | | 6 | ^ | ^ | ^ | | | 7 | | | ^ | | | 8 | ^ | ^ | ^ | | | 9 | | | ^ | | | 10 | ^ | ^ | ^ | |
For all testdata, it is guaranteed that , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号