Codeforces Round 1057 (Div. 2)
B
Bitwise Reversion
Codeforces
800
原题
← AC →
翻译中…

You are given three non-negative integers $x$, $y$ and $z$. Determine whether there exist three non-negative integers $a$, $b$ and $c$ satisfying the following three conditions:

翻译中…
  • $a \mathbin{\&} b = x$
  • $b \mathbin{\&} c = y$
  • $a \mathbin{\&} c = z$
翻译中…

where $\mathbin{\&}$ denotes the bitwise AND operation.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first and only line of each test case contains three integers $x$, $y$ and $z$ ($0\le x, y, z\le 10^9$) — the target values of $a \mathbin{\&} b$, $b \mathbin{\&} c$ and $a \mathbin{\&} c$, respectively.

翻译中…

Output

翻译中…

For each test case, output "YES" if there exists three non-negative integers $a$, $b$, and $c$ satisfying the above conditions, and "NO" otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, $a = 3$, $b = 5$, and $c = 9$ satisfies the condition as $3 \mathbin{\&} 5 = 1$, $5 \mathbin{\&} 9 = 1$, and $3 \mathbin{\&} 9 = 1$.

翻译中…

In the second test case, $a = 7$, $b = 3$, and $c = 22$ satisfies the condition as $7 \mathbin{\&} 3 = 3$, $3 \mathbin{\&} 22 = 2$, and $7 \mathbin{\&} 22 = 6$.

翻译中…

In the third test case, it can be proven that there are no three non-negative integers $a$, $b$, and $c$ such that $a \mathbin{\&} b = 4$, $b \mathbin{\&} c = 8$, and $a \mathbin{\&} c = 12$.

翻译中…

样例

Input #1
5
1 1 1
3 2 6
4 8 12
9 10 12
12730 3088 28130
Output #1
YES
YES
NO
YES
NO
InputCopy OutputCopy
题目信息
题号
2153B
时间限制
1.5 s
内存限制
256 MB
标签
位运算
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。