#P10408. 「SMOI-R1」Apple
「SMOI-R1」Apple
Background
To filter out incorrect algorithms, we changed the time limit to 680 ms.
Problem Description
LAR has apples. The apples are numbered from to . The value of the apple with number is .
If , then we say that contains (where is bitwise OR).
Since LAR has too many apples, he does not know how to choose apples. He wants to perform some operations so that it is more convenient for him to eat apples.
There are two types of operations, for a total of operations:
- : Query the sum of values of all apples whose indices are contained in .
- : Change the value of the apple with index to (set to ).
Input Format
The first line contains two integers and , where is the number of operations.
The second line contains numbers. The -th number represents the value of .
The next lines each describe one operation that LAR will perform, as detailed above.
Output Format
For each operation of type , output one number, which is the answer to the query.
2 5
1 2 3 2
1 2
2 0 4
1 2
2 3 1
1 3
4
7
10
Hint
Sample Explanation
Initially, .
In the first operation, we query the sum of values of all apples whose indices are contained in . The numbers contained in are , so the answer is .
In the second operation, we change to , so now .
In the third operation, we query the sum of values of all apples whose indices are contained in . The numbers contained in are , so the answer is .
In the fourth operation, we change to , so now .
In the fifth operation, we query the sum of values of all apples whose indices are contained in . The numbers contained in are , so the answer is .
Constraints
This problem uses bundled testdata.
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| None | ||||
| Only operation 1 | ||||
| None | ||||
For of the testdata, it is guaranteed that , , and .
Hint: The input size of this problem is large, so please use fast input. Please pay attention to the constant factors in your code.
Translated by ChatGPT 5