#P14457. [ICPC 2025 Xi'an R] Killing Bits
[ICPC 2025 Xi'an R] Killing Bits
题目描述
You are given two arrays and , both consisting of non-negative integers. You can perform the following operation on the array an arbitrary number of times (possibly, zero):
- First, you select a permutation of ;
- Then, for each , you set to . Here, denotes the bitwise AND operation.
You have to determine whether it is possible to transform into .
输入格式
The input consists of multiple test cases. The first line contains an integer (), the number of test cases. For each test case:
- The first line contains a single integer (), which is the length of arrays and .
- The second line contains integers (), which are the elements of .
- The third line contains integers (), which are the elements of .
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print in a single line if it is possible to transform into . Otherwise, print .
You can output the answer in any case (upper or lower). For example, the strings , , , and will be recognized as positive responses.
4
3
0 1 2
2 1 0
5
1 0 1 3 4
0 0 1 1 4
8
1 2 3 4 5 6 7 7
1 2 3 4 5 6 7 7
8
7 7 7 7 7 7 7 7
1 2 3 4 5 6 7 7
No
Yes
Yes
No
提示
In the first test case, we need to use at least one operation to transform into . Note that is always because . However, , so it is impossible to make , no matter how the permutations are selected during the operations.
In the second test case, you can select . After this operation, is transformed into .
In the third test case, , so we do not need any operations.
京公网安备 11011102002149号