#ABC470C. 自增、自减与异或 / Inc, Dec, Xor
自增、自减与异或 / Inc, Dec, Xor
Problem Statement
There is a length- integer sequence . Initially, all elements of are .
You will be given queries, which should be processed in order. There are two types of queries, each given in one of the following formats:
1 x: Increase the value of by .2: For each , if , decrease the value of by .
Find the bitwise of immediately after processing each query.
What is bitwise ?
The bitwise of non-negative integers and , denoted , is defined as follows:
- In the binary representation of , the digit in the () place is if exactly one of the digits in the place of and in their binary representations is , and otherwise.
For example, (in binary: ).
More generally, the bitwise of non-negative integers is defined as $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$, and it can be proved that this value does not depend on the order of .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $Q$
$\text{query}_1$
$\text{query}_2$
$\vdots$
$\text{query}_Q$
Each query is given in one of the following formats:
$1$ $x$
$2$
Output
Output lines.
The -th line should contain the bitwise of for immediately after processing the -th query.
2 5
1 2
1 2
1 1
2
2
1
2
3
1
0
After processing the first query, . The bitwise of is , so output on the first line.
After processing the second query, . The bitwise of is , so output on the second line.
After processing the third query, . The bitwise of is , so output on the third line.
After processing the fourth query, . The bitwise of is , so output on the fourth line.
After processing the fifth query, . The bitwise of is , so output on the fifth line.
3 8
1 2
1 3
1 1
1 2
1 1
2
1 3
1 1
1
0
1
2
1
0
1
2
相关
在下列比赛中: