-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1842B Tenzing and Books.cpp
64 lines (60 loc) · 1.18 KB
/
1842B Tenzing and Books.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
author : MishkatIT
created : Saturday 2023-06-24-21.28.18
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(_) cout << #_ << " is " << _ << '\n';
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 10;
const ll inf = 1e9;
const ll linf = 1e18;
int target, n, x;
void check(vector<int>& v)
{
for (int i = 0; i < n; i++)
{
for(int j = 0; j < 31; j++)
{
int zz = 1 << j;
if(!(x & zz) && (v[i] & zz)) return;
}
target |= v[i];
}
}
int main()
{
fio;
int t;
cin >> t;
while(t--)
{
target = 0;
cin >> n >> x;
vector<int> a(n);
for (auto& x: a)
{
cin >> x;
}
vector<int> b(n);
for (auto& x: b)
{
cin >> x;
}
vector<int> c(n);
for (auto& x: c)
{
cin >> x;
}
check(a);
if(target != x) check(b);
if(target != x) check(c);
if(target == x)
cout << "YES" << '\n';
else
cout << "NO" << '\n';
}
return 0;
}