Source Code

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
      ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   ll n,m;
   cin>>n>>m;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
     ll x,y,z;
     int c=0,a=0;
    for(int i=0;i<n;i++){
   a=1;
        x=arr[i];y=arr[i];z=arr[i];
        if(x==m){
        c=max(c,1);
        }
       
        for(int j=i+1;j<n;j++){
        
        x=(x&arr[j]);
        y|=arr[j];
        z^=arr[j];a++;
         if(x==m&&y==m&&z==m)
        c=max(c,a);
        }
    }
    cout<<c<<"\n";
    
    return 0;
}
Copy
Legendary ateeq
GNU G++17
3 ms
976 KB
Wrong Answer