#P6617. 查找 Search

查找 Search

Description

Given nn trash bins, you need to maintain a data structure that supports the following operations:

  • 1 pos val means changing the label in the pospos-th trash bin to valval.

  • 2 l r asks whether there exist two trash bins in [lcnt,rcnt][l\oplus cnt, r\oplus cnt] whose labels sum to ww.

Here, \oplus denotes the XOR operation, and cntcnt is the number of answers equal to Yes before this query.

For each operation of type 2, output Yes if such a pair exists; otherwise output No.

Note that for all queries, ww is the same number.

Input Format

The first line contains three integers n,m,wn, m, w, representing the length of the sequence, the number of subsequent operations, and ww.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n, describing the label aa in each trash bin.

The next mm lines each contain three integers in the format opt x y.

Output Format

Let the number of type 2 operations be tt. Output tt lines in total.

The ii-th line is the result of the ii-th type 2 operation, i.e., Yes or No.

6 4 6
1 3 2 5 5 6
2 1 4
1 4 1
2 0 5
2 3 7
Yes
No
Yes
10 20 10
9 3 6 3 3 3 3 1 4 9
1 3 9
1 6 9
2 3 10
1 3 9
2 4 4
1 1 7
1 1 3
1 5 6
1 3 9
2 4 7
1 2 7
2 6 8
1 6 10
2 2 9
1 7 9
2 3 1
1 3 5
1 5 6
1 9 10
1 3 6
Yes
No
No
No
Yes
Yes

Hint

This problem uses bundled tests, with O2 optimization enabled.

Subtask 1 (7 pts):\text{Subtask 1 (7 pts)}: Guaranteed 1n,m,w21031 \le n, m, w \le 2\cdot10^3, time limit 1s1\text{s}.

Subtask 2 (20 pts):\text{Subtask 2 (20 pts)}: Guaranteed 1n,m,w11051 \le n, m, w \le 1\cdot10^5, opt=2opt = 2, time limit 2s2\text{s}.

Subtask 3 (30 pts):\text{Subtask 3 (30 pts)}: Guaranteed 1n,m,w11051 \le n, m, w \le 1\cdot10^5, time limit 2s2\text{s}.

Subtask 4 (43 pts):\text{Subtask 4 (43 pts)}: No special restrictions, time limit 4s4\text{s}.

For all testdata, 1n,m,w51051 \le n, m, w \le 5\cdot10^5, 0aiw0 \le a_i \le w.

The testdata guarantees that for each operation, 1posn1 \le pos \le n, 0valw0 \le val \le w, and 1lcntrcntn1 \le l \oplus cnt \le r \oplus cnt \le n.

Since the input and output are large, faster I/O methods are recommended.


Explanation for Sample Input #1

In the first operation, we query whether there are two numbers in the interval [1,4][1, 4] that sum to 66. Obviously, a1+a4=6a_1 + a_4 = 6, so output Yes.

In the second operation, modify a4a_4 to 11, so the sequence becomes [1,3,2,1,5,6][1, 3, 2, 1, 5, 6].

In the third operation, query whether there are two numbers in the interval [1,4][1, 4] that sum to 66. There are none, so output No.

In the fourth operation, query whether there are two numbers in the interval [2,6][2, 6] that sum to 66. Obviously, a4+a5=6a_4 + a_5 = 6, so output Yes.

Translated by ChatGPT 5