-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeChef.cpp
75 lines (66 loc) · 1.12 KB
/
codeChef.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
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin>>n;
unordered_set<long long> st;
long long totalOr=0;
bool ans=true;
long long *arr=new long long[n];
for(int i=0 ;i<n ; i++){
cin>>arr[i];
}
st.insert(arr[0]);
totalOr=arr[0];
for(int i=1 ; i<n && ans ; i++){
if(st.find(arr[i])==st.end()){
st.insert(arr[i]);
}else{
ans=false;
}
if( st.find(totalOr | arr[i])==st.end()){
st.insert(totalOr | arr[i]);
}else{
ans=false;
}
if(i>1){
if( st.find(arr[i] | arr[i-1])==st.end()){
st.insert(arr[i] | arr[i-1]);
}else{
ans=false;
}
}
}
if(ans){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--) solve();
}
/*
if(st.find(curr)==st.end())
st.insert(curr);
else
ans=false;
if(last){
if( st.find(curr | last)==st.end())
st.insert(curr | last);
else
ans=false;
}
if(totalOr){
if(st.find(totalOr | curr)==st.end())
st.insert(totalOr | curr);
else
ans=false;
}
last=curr;
totalOr |=curr;
*/