CF1842B.Tenzing and Books
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Tenzing received 3n books from his fans. The books are arranged in 3 stacks with n books in each stack. Each book has a non-negative integer difficulty rating.
Tenzing wants to read some (possibly zero) books. At first, his knowledge is 0.
To read the books, Tenzing will choose a non-empty stack, read the book on the top of the stack, and then discard the book. If Tenzing's knowledge is currently u, then his knowledge will become u∣v after reading a book with difficulty rating v. Here ∣ denotes the bitwise OR operation. Note that Tenzing can stop reading books whenever he wants.
Tenzing's favourite number is x. Can you help Tenzing check if it is possible for his knowledge to become x?
丹增从他的粉丝那里收到了 3n 本书。这些书被分成 3 堆,每堆恰好有 n 本书。每本书都有一个非负整数难度值。
丹增希望阅读其中一些(可能为零本)书。初始时,他的知识值为 0。
在阅读过程中,丹增每次选择一个非空的书堆,阅读该堆最上方的一本书,然后将这本书丢弃。若丹增当前的知识值为 u,当他阅读一本难度值为 v 的书后,他的知识值将变为 u∣v。此处 ∣ 表示按位或运算。注意:丹增可以在任意时刻停止阅读。
丹增最喜爱的数字是 x。你能帮丹增判断:是否存在一种阅读方案,使得他的知识值最终恰好等于 x?
输入格式
Each test contains multiple test cases. The first line of input contains a single integer t (1≤t≤104) — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers n and x (1≤n≤105, 0≤x≤109) — the number of books in each stack and Tenzing's favourite number.
The second line of each test case contains n integers a1,a2,…,an (0≤ai≤109) — the difficulty rating of the books in the first stack, from top to bottom.
The third line of each test case contains n integers b1,b2,…,bn (0≤bi≤109) — the difficulty rating of the books in the second stack, from top to bottom.
The fourth line of each test case contains n integers c1,c2,…,cn (0≤ci≤109) — the difficulty rating of the books in the third stack, from top to bottom.
It is guaranteed that the sum of n does not exceed 105.
每个测试包含多个测试用例。输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 x(1≤n≤105,0≤x≤109)—— 分别表示每堆书的数量以及丹增最喜爱的数字。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(0≤ai≤109)—— 表示第一堆书中各本书的难度值,从上到下排列。
每个测试用例的第三行包含 n 个整数 b1,b2,…,bn(0≤bi≤109)—— 表示第二堆书中各本书的难度值,从上到下排列。
每个测试用例的第四行包含 n 个整数 c1,c2,…,cn(0≤ci≤109)—— 表示第三堆书中各本书的难度值,从上到下排列。
保证所有测试用例中 n 的总和不超过 105。
输出格式
For each test case, output "Yes" (without quotes) if Tenzing can make his knowledge equal to x, and "No" (without quotes) 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.
对于每个测试用例,如果丹增能够使其知识值等于 x,则输出“Yes”(不带引号);否则输出“No”(不带引号)。
您可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。
输入输出样例
输入#1
3 5 7 1 2 3 4 5 5 4 3 2 1 1 3 5 7 9 5 2 3 2 3 4 5 5 4 3 2 1 3 3 5 7 9 3 0 1 2 3 3 2 1 2 2 2
输出#1
Yes No Yes
说明/提示
For the first test case, Tenzing can read the following 4 books:
- read the book with difficulty rating 1 on the top of the first stack. Tenzing's knowledge changes to 0∣1=1.
- read the book with difficulty rating 1 on the top of the third stack. Tenzing's knowledge changes to 1∣1=1.
- read the book with difficulty rating 2 on the top of the first stack. Tenzing's knowledge changes to 1∣2=3.
- read the book with difficulty rating 5 on the top of the second stack. Tenzing's knowledge changes to 3∣5=7.
After reading all books, Tenzing's knowledge is 7.
For the third test case, Tenzing can read 0 books to make his final knowledge equals to 0.
对于第一个测试用例,丹增可以阅读以下 4 本书:
- 阅读第一堆顶部难度评分为 1 的书。丹增的知识值变为 0∣1=1。
- 阅读第三堆顶部难度评分为 1 的书。丹增的知识值变为 1∣1=1。
- 阅读第一堆顶部难度评分为 2 的书。丹增的知识值变为 1∣2=3。
- 阅读第二堆顶部难度评分为 5 的书。丹增的知识值变为 3∣5=7。
阅读完所有这些书后,丹增的知识值为 7。
对于第三个测试用例,丹增可以不阅读任何书,使其最终知识值等于 0。
输入解题思路,AI测评打分。不知道怎么写?