The difference between the two is that in your AC solution you also consider OR(l,l) (both arguments the same), whereas in your WA solution this is not checked.
I am inserting v[j] in set and assigning x=v[j] so i hv checked OR(l,l)
Can you please tell me why is this code getting wrong answer on 1?
Though it passed all the cases I’ve seen people given here… I just checked if an element is able to contribute a unique position with 1 (set it) and if it’s true for all elements then I output yes otherwise no…
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t --) {
bool ok=true,unq=false;
int n;
vectorar (61,0);
cin>>n;
vectorv;
long long int x;
for(int i=0; i<n; i++) {
cin>>x;
v.push_back(x);
for(int j=0; j<61; j++) {
if(((1LL<<j)&x) !=0)ar[j]++;
}
}
for(int i=0; i<n; i++) {
unq=false;
for(int j=0; j<61; j++) {
if((((1LL<<j)&v[i]) !=0LL) & (ar[j]==1)) {
unq=true;
break;
}
}
if(!unq) {
ok=false;
}
if(!ok)break;
}
if(!ok)
{
cout<<"NO"<<endl;
}
else {
cout<<"YES"<<endl;
}
}
}