#P6747. 『MdOI R3』Teleport
『MdOI R3』Teleport
Description
Matt Horner wants to control the Hyperion to perform a warp. To warp, he must activate all nodes on the Hyperion.
There are nodes on the Hyperion. The -th node has energy. To activate them, Matt Horner will consume units of terrazine. These units of terrazine are evenly distributed to the nodes. After each node receives units of terrazine, it will be triggered and gain units of high energy. The total sum of high energy over all nodes is the warp cost .
To warp as fast as possible, Matt Horner decides to use as much as units of terrazine as possible. Unfortunately, if too much terrazine is used so that the cost exceeds the limit , the Hyperion will be overloaded and eventually explode.
Now, your task is to help Matt Horner find the maximum such that the Hyperion can warp away as fast as possible while staying safe. If it is impossible to warp safely under any circumstances, output .
Here, denotes the bitwise XOR operation.
Input Format
The first line contains an integer , the number of nodes.
The second line contains integers , representing the energy of each node.
The third line contains an integer , the number of queries.
The next lines describe the queries. Each line contains one number .
Output Format
For each query, output one line containing a non-negative integer, the maximum . If there is no solution, output .
3
1 2 3
2
10
1
3
-1
1
0
1
1073741824000000
1073741824000000
Hint
For the first query, the maximum is . At this time, . It can be proven that no larger satisfies the condition.
For the second query, there is no that satisfies the condition.
| Test Point | ||||
|---|---|---|---|---|
This problem does not use bundled tests.
The Constraints for all test points are shown above. For all data, $0<n,q\leq 10^5,\ 0\leq a_i\leq 2^{30},\ 0\leq m\leq 2^{30}\times 10^6$.
Translated by ChatGPT 5
京公网安备 11011102002149号