luogu#P4991. 愤怒的XiaoX
愤怒的XiaoX
Background
For Q&A, please go to https://www.luogu.org/discuss/show?postid=79498.
A few days ago, in a mock contest, got again and again.
He wanted to make things harder for everyone, so he created the following problem.
Problem Description
Given a sequence, you need to maintain the following operations:
: bitwise NOT the last bits of the numbers from to .
: reverse the last bits of the numbers from to .
: query the value at position .
To reduce the difficulty of this problem, we make the following rules:
For operations on the sequence, the values are fixed within a certain range.
There are a total of different values.
After each , there are some operations.
In these operations, the (the number of modified bits) is the same.
Definition of bitwise NOT:
For example, the binary representation of a number is:
10100111
After taking bitwise NOT on the last 5 bits, it becomes:
10111000
Definition of reverse:
For example, the binary representation of a number is:
10100111
After reversing the last 5 bits, it becomes:
10111100
Input Format
The first line contains two integers and , representing the length of the sequence and the number of values.
The second line contains numbers, representing the initial sequence.
Then follow groups of operations. For each group, the first line contains two numbers and , representing the number of operations and the value of used in these operations.
The next lines describe the operations in this group.
Output Format
For each operation of type , output one line with one integer, representing the answer.
5 2
665667089 948925818 1118302620 288255565 1682529647
5 2
1 3 4
3 1
2 3 5
2 2 4
3 4
5 25
1 3 3
1 3 4
3 1
2 1 5
2 1 3
665667089
288255566
665667089
Hint
For of the data, there are no operations of type or .
For another of the data, there are no operations of type .
For another of the data, there are no operations of type .
For of the data, .
For of the data, .
For of the data, , , , . The initial sequence is generated by (on Windows).
Thanks to @swhsz for verifying the problem.
Translated by ChatGPT 5