#P6617. Garbage Bins Query
Garbage Bins Query
Garbage Bins Query
You are given n garbage bins, each containing a garbage number. You need to design a data structure to support the following two types of operations:
1 pos val
: Replace the garbage number of the bin at position pos with val.2 l r
: Query whether there exists two distinct bins within the interval \([l \oplus cnt,\; r \oplus cnt]\) whose garbage numbers sum to \(w\). Here, \(\oplus\) denotes the bitwise XOR operation and \(cnt\) is the number of previous queries (type 2) whose answer was "Yes" (note that \(cnt\) is updated before processing the current query).
Note: For every query operation of type 2, the target sum \(w\) is the same fixed number. In addition, if after applying XOR the interval endpoints are out of range, you should clamp them into the interval \([1, n]\) and if the left endpoint exceeds the right endpoint, swap them.
Your task is to process all operations and for each query (type 2) output "Yes" if such a pair exists, otherwise output "No".
inputFormat
The input begins with a line containing three integers \(n\), \(m\), and \(w\) where \(n\) is the number of garbage bins, \(m\) is the number of operations, and \(w\) is the fixed target sum.
The second line contains \(n\) integers, representing the initial garbage numbers in bins \(1, 2, \ldots, n\).
The next \(m\) lines each contain an operation in one of the following formats:
1 pos val
— update the garbage number at bin pos to val.2 l r
— query if there exist two different bins in the interval defined by \([l \oplus cnt,\; r \oplus cnt]\) (after appropriate clamping and ordering) whose numbers sum to \(w\).
outputFormat
For each query operation (type 2), output a single line containing either "Yes" if there exists a pair of bins whose garbage numbers sum to \(w\), or "No" if no such pair exists.
sample
5 5 10
3 7 2 8 1
2 1 5
1 3 5
2 2 5
1 5 7
2 3 5
Yes
No
No
</p>