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=0;
        x=arr[i];y=arr[i];z=arr[i]; if(x==m&&y==m&&z==m)a++;
        for(int j=i+1;j<n;j++){
       
     
        x=(x&arr[j]);
        y|=arr[j];
        z^=arr[j];
        if(x==m&&y==m&&z==m)a++;
        } c=max(c,a);
    }
    cout<<c<<"\n";
    
    return 0;
}
Copy
Legendary ateeq
GNU G++17
2 ms
916 KB
Wrong Answer