fork download
  1. // #pragma GCC optimize("Ofast")
  2. // #pragma GCC optimize ("unroll-loops")
  3. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  4. #include<bits/stdc++.h>
  5. #define ll long long
  6. #define f(i,a,b) for(int i=a;i<b;i++)
  7. #define mod 1000000007
  8. #define pie 3.14159265359
  9. #define mp make_pair
  10. #define ff first
  11. #define ss second
  12. #define rf(i,a,b) for(int i=a;i>=b;i--)
  13. #define sc(a) scanf("%lld",&a)
  14. #define pf printf
  15. #define sz(a) (ll)(a.size())
  16. #define psf push_front
  17. #define ppf pop_front
  18. #define ppb pop_back
  19. #define pb push_back
  20. #define pq priority_queue
  21. #define all(s) s.begin(),s.end()
  22. #define sp(a) setprecision(a)
  23. #define rz resize
  24. #define ld long double
  25. #define inf 1e15
  26. #define ub upper_bound
  27. #define lb lower_bound
  28. #define bs binary_search
  29. #define eb emplace_back
  30. #define out fflush(stdout);
  31.  
  32. using namespace std;
  33.  
  34. int main()
  35. {
  36. ios_base::sync_with_stdio(false);
  37. cin.tie(NULL);
  38. // freopen("input.txt","r",stdin);
  39. // freopen("output.txt","w",stdout);
  40. int t;
  41. cin>>t;
  42. while(t--)
  43. {
  44. int n;
  45. cin>>n;
  46. vector<ll> a(n);
  47. f(i,0,n)
  48. cin>>a[i];
  49. bool flag=1;
  50. ll val=a[0];
  51. f(i,1,n)
  52. {
  53. if(val==a[i] || (val|a[i])==a[i] || (val|a[i])==val)
  54. {
  55. // cout<<val<<' '<<(val|a[i])<<"\n";
  56. flag=0;
  57. break;
  58. }
  59. val|=a[i];
  60. }
  61. if(flag)
  62. cout<<"YES\n";
  63. else
  64. cout<<"NO\n";
  65. }
  66. }
Success #stdin #stdout 0s 4224KB
stdin
4
3
1 2 7
2
1 2
3
6 5 8
5
12 32 45 23 4
stdout
NO
YES
YES
NO