#P15134. [ROIR 2026] XOR 染色
[ROIR 2026] XOR 染色
Problem Description
Given two non-negative integer arrays and .
Define . In other words, is the set of indices in array such that the bitwise XOR of and is at most .
Find the minimum number such that the elements in array can be colored using colors, and the following condition holds: if and intersect, then and must be colored with different colors.
That is, you need to find such that , and if , then .
As a reminder, the bitwise XOR (, xor) of two non-negative integers is defined as follows: write both numbers in binary, and the -th bit of the result is 1 if and only if exactly one of the two numbers has a 1 in that bit. For example, $(14 \text{ xor } 7) = (1110_2 \oplus 0111_2) = 1001_2 = 9$. This operation is implemented in all modern programming languages: it is written as ^ in C++, Java, and Python, and as xor in Pascal.
Input Format
The input contains multiple test cases.
The first line contains an integer , the number of test cases.
The following lines describe the test cases.
The first line of each test case contains three integers , , and (, ).
The second line contains integers , the elements of array ().
The third line contains integers , the elements of array ().
It is guaranteed that the sum of over all test cases and the sum of over all test cases are both at most .
Output Format
For each test case, output one integer, the required minimum .
3
2 2 0
0 0
1 1
5 5 3
0 1 2 3 4
0 1 2 3 4
5 5 4
0 1 2 3 4
0 1 2 3 4
1
4
5
Hint
Scoring Rules
| Subtask | Points | Additional Constraints | Required Subtasks |
|---|---|---|---|
| 1 | 5 | --- | |
| 2 | 1 | ||
| 3 | 1, 2 | ||
| 4 | 1–3 | ||
| 5 | 1–4 | ||
| 6 | 10 | 1–5 | |
| 7 | 5 | , | --- |
| 8 | 10 | , | |
| 9 | 5 | ; | |
| 10 | ; | 9 | |
| 11 | 35 | No additional constraints. | 1–10 |
Translated by ChatGPT 5