#P6562. [SBCOI2020] 归家之路
[SBCOI2020] 归家之路
Description
There are stars in the sky, numbered in order. Each star has a brightness value. Initially, the brightness of star is .
For two positive integers , we define a Boolean operation . If, in the binary representation of , every bit where is also has the corresponding bit of equal to , then is True; otherwise, it is False.
If the two numbers have different bit lengths in binary, align them to the right and pad zeros on the left. For example, for and (in binary), becomes .
There are two types of operations on the brightness values:
-
. For all such that is
Trueand isTrue, add to the brightness of star . -
. For all such that is
Trueand is `True$, compute the sum of the brightness values of all such stars$c$, and output the result modulo .
Input Format
The first line contains two integers .
The second line contains integers separated by spaces, representing .
The next lines each describe one operation, in the format given in the Description.
Output Format
For each operation of type , output one line containing the answer.
3 3
1 2 3 4 5 6 7 8
2 0 7
1 1 5 1
2 1 7
36
22
Hint
Sample Explanation
The first operation is a query. The binary representation of is , and the binary representation of is . At this time, all numbers satisfy the condition, so we take the sum of all numbers, which is .
The second operation is an update. The binary representation of is , and the binary representation of is . We find that satisfy the condition, with binary representations and respectively, so change from to .
The third operation is a query. The binary representation of is , and the binary representation of is . We find that satisfy the condition, with binary representations , , , respectively. We need the sum .
Constraints
This problem uses bundled testdata and has subtasks.
: The answers match the sample.
: .
: All type operations occur after type operations.
: No additional restrictions.
For of the testdata, $1 \le n \le 16,1 \le m \le 2\times 10^5, 0 \le a,b \le 2^n-1,0 \le a_i,k \le 2^{32}-1$.
Friendly Reminder
To take modulo , you can directly use an unsigned 32-bit integer type for computations. In c++, this is unsigned int.
That is, just let it overflow naturally and nothing will happen.
Translated by ChatGPT 5
京公网安备 11011102002149号