Codeforces Round 1005 (Div. 2) |
---|
Finished |
There are $$$n$$$ slimes on a line, the $$$i$$$-th of which has weight $$$w_i$$$. Slime $$$i$$$ is able to eat another slime $$$j$$$ if $$$w_i \geq w_j$$$; afterwards, slime $$$j$$$ disappears and the weight of slime $$$i$$$ becomes $$$w_i \oplus w_j$$$$$$^{\text{∗}}$$$.
The King of Slimes wants to run an experiment with parameter $$$x$$$ as follows:
The King of Slimes is going to ask you $$$q$$$ queries. In each query, you will be given an integer $$$x$$$, and you need to determine the score of the experiment with parameter $$$x$$$.
Note that the King does not want you to actually perform each experiment; his slimes would die, which is not ideal. He is only asking what the hypothetical score is; in other words, the queries are not persistent.
$$$^{\text{∗}}$$$Here $$$\oplus$$$ denotes the bitwise XOR operation.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains integers $$$n$$$ and $$$q$$$ ($$$1 \le n, q \le 2 \cdot 10^5$$$) — the number of slimes and the number of queries, respectively.
The following line contains $$$n$$$ integers $$$w_1,w_2,\ldots,w_n$$$ ($$$1 \le w_i < 2^{30}$$$) — the weights of the slimes.
The following $$$q$$$ lines contain a single integer $$$x$$$ ($$$ 1 \le x < 2^{30}$$$) — the parameter for the experiment.
The sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ and the sum of $$$q$$$ does not exceed $$$2 \cdot 10^5$$$ across all test cases.
For each query, output a single integer — the score of the experiment.
31 1564 41 5 4 11813161510 910 4 3 9 7 4 6 1 9 4265698627
1 0 2 4 2 0 1 1 1 3 3 1 0 1
For the first query of the second testcase:
Name |
---|