luogu#P4735. 最大异或和

    ID: 3696 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化可持久化前缀和字典树 Trie

最大异或和

Problem Description

You are given a sequence of non-negative integers {a}\{a\} with initial length NN.

There are MM operations of the following two types:

  1. A x: an append operation, meaning that a number xx is appended to the end of the sequence, and the length NN increases by 11.
  2. Q l r x: a query operation. You need to find a position pp such that lprl \le p \le r, to maximize a[p]a[p+1]...a[N]xa[p] \oplus a[p+1] \oplus ... \oplus a[N] \oplus x, and output the maximum value.

Input Format

The first line contains two integers N,MN, M, as described above.
The second line contains NN non-negative integers, representing the initial sequence AA.
The next MM lines each describe one operation, in the format given in the statement.

Output Format

Suppose there are TT query operations. Output TT lines, each containing one integer, which is the answer to a query.

5 5
2 6 4 3 6
A 1 
Q 3 5 4 
A 4
Q 5 7 0 
Q 3 6 6 
4
5
6

Hint

  • For all test cases, 1N,M3×1051 \le N, M \le 3 \times 10 ^ 5, 0ai1070 \le a_i \le 10 ^ 7.

Translated by ChatGPT 5