-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
83 lines (81 loc) · 1.84 KB
/
B.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long a[100005],b[100005],c[100005];
int main()
{
fastio;
long long t,n,x,i,p,q,r,j,flag,ans;
cin>>t;
while(t--)
{
p=-1;
q=-1;
r=-1;
ans=0;
cin>>n>>x;
for(i=0;i<n;i++){
cin>>a[i];
if(p==-1)
{
flag=0;
for(j=0;(1<<j)<=a[i];j++)
{
if((a[i]&(1<<j)) && (!(x&(1<<j))))
{
flag=1;
break;
}
}
if(flag==1)
p=i;
else
ans|=a[i];
}
}
for(i=0;i<n;i++){
cin>>b[i];
if(q==-1)
{
flag=0;
for(j=0;(1<<j)<=b[i];j++)
{
if((b[i]&(1<<j)) && (!(x&(1<<j))))
{
flag=1;
break;
}
}
if(flag==1)
q=i;
else
ans|=b[i];
}
}
for(i=0;i<n;i++){
cin>>c[i];
if(r==-1)
{
flag=0;
for(j=0;(1<<j)<=c[i];j++)
{
if((c[i]&(1<<j)) && (!(x&(1<<j))))
{
flag=1;
break;
}
}
if(flag==1)
r=i;
else
ans|=c[i];
}
}
if(ans==x)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}