#P17209. 「DLESS-6」XOR and Your Problem

「DLESS-6」XOR and Your Problem

Background

You created this problem.

Problem Description

You are given a sequence aa of nn non-negative integers and qq queries. For each query, given l,rl, r, find:

max⁡l≤i≤j≤r(ai⊕aj)\max_{l\le i\le j\le r}(a_i\oplus a_j)

Here, ⊕\oplus denotes the bitwise XOR operation.

Input Format

The first line contains two positive integers n,qn, q.

The second line contains nn non-negative integers, representing the sequence aa.

The next qq lines each contain two integers l,rl, r, representing one query.

Output Format

For each query, output one number per line, representing the answer.

5 5
3 4 6 7 1
3 4
1 2
3 5
4 5
4 4

1
7
7
6
0

8 10
11 14 10 12 3 6 15 11
2 3
3 4
2 7
2 4
3 8
5 6
2 5
8 8
5 8
1 4

4
6
15
6
15
5
15
0
13
7

Hint

For all testdata, it is guaranteed that:

  • 1≤n,q≤3⋅1051\le n, q\le 3\cdot 10^5.
  • 0≤ai<2300\le a_i<2^{30}.
  • 1≤l≤r≤n1\le l\le r\le n.

This problem uses bundled tests, and the special properties of each subtask are as follows:

Subtask ID n≤n\le q≤q\le Score
11 600600 55
22 40004000 66
33 80008000 3⋅1053\cdot 10^5 2020
44 7⋅1047\cdot 10^4 7⋅1047\cdot 10^4 2525
55 2⋅1052\cdot 10^5 3333
66 3⋅1053\cdot 10^5 1111

Translated by ChatGPT 5