A16241 | Friendly Arrays
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two arrays of integers — $a_1, \ldots, a_n$ of length $n$ , and $b_1, \ldots, b_m$ of length $m$ . You can choose any element $b_j$ from array $b$ ( $1 \leq j \leq m$ ), and for all $1 \leq i \leq n$ perform $a_i = a_i | b_j$ . You can perform any number of such operations.
After all the operations, the value of $x = a_1 \oplus a_2 \oplus \ldots \oplus a_n$ will be calculated. Find the minimum and maximum values of $x$ that could be obtained after performing any set of operations.
Above, $|$ is the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR), and $\oplus$ is the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
After all the operations, the value of $x = a_1 \oplus a_2 \oplus \ldots \oplus a_n$ will be calculated. Find the minimum and maximum values of $x$ that could be obtained after performing any set of operations.
Above, $|$ is the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR), and $\oplus$ is the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 10^4$ ) — the number of test cases. This is followed by the description of the test cases.
The first line of each test case contains two integers $n$ and $m$ ( $1 \leq n, m \leq 2 \cdot 10^5$ ) — the sizes of arrays $a$ and $b$ .
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \leq a_i \leq 10^9$ ) — the array $a$ .
The third line of each test case contains $m$ integers $b_1, b_2, \ldots, b_m$ ( $0 \leq b_i \leq 10^9$ ) — the array $b$ .
It is guaranteed that the sum of values of $n$ and $m$ across all test cases does not exceed $2 \cdot 10^5$ .
The first line of each test case contains two integers $n$ and $m$ ( $1 \leq n, m \leq 2 \cdot 10^5$ ) — the sizes of arrays $a$ and $b$ .
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \leq a_i \leq 10^9$ ) — the array $a$ .
The third line of each test case contains $m$ integers $b_1, b_2, \ldots, b_m$ ( $0 \leq b_i \leq 10^9$ ) — the array $b$ .
It is guaranteed that the sum of values of $n$ and $m$ across all test cases does not exceed $2 \cdot 10^5$ .
输出格式
For each test case, output $2$ numbers: the minimum and maximum possible values of $x$ after performing any set of operations.
输入输出样例
输入 #1
2 2 3 0 1 1 2 3 3 1 1 1 2 1
输出 #1
0 1 2 3
In the first test case, if we apply the operation with element $b_1 = 1$ , the array $a$ will become $[1, 1]$ , and $x$ will be $0$ . If no operations are applied, then $x = 1$ .
In the second test case, if no operations are applied, then $x = 2$ . If we apply the operation with $b_1 = 1$ , then $a = [1, 1, 3]$ , and $x = 3$ .
In the second test case, if no operations are applied, then $x = 2$ . If we apply the operation with $b_1 = 1$ , then $a = [1, 1, 3]$ , and $x = 3$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted