Source Code
#include <bits/stdc++.h>
#define ll  long long
#define ss second
#define ff first
#define sz size()
#define el '\n'
#define tc ll tt; cin>>tt; while(tt--)
using namespace std;

void fastIO() {
	ios::sync_with_stdio(false);
	cout.tie(nullptr);
	cin.tie(nullptr);
}

const ll N = 2e5 + 5;
bool d[N];

int main(){
    fastIO();
    ll n, d, ans = 0,res = 0,e = 0,s = 0;
    cin >> n >> d;
    vector<ll> v(n);
    for (int i = 0;i < n;i++){
        cin >> v[i];
        ll k = (v[i] & d);
        if (v[i] == d || v[i] & d == v[i]){
            res++;
            s ^= v[i];
            if (s == d) ans = max(ans, res);
            //cout << s << el;
        }
        else {
            if (s == d) ans = max(ans, res);
            e = 0;
            s = 0;
            res = 0;
        }
    }
    if (s == d) ans = max(ans, res);
    cout << ans << el;
}
Copy
Legendary heba.daraghmeh
GNU G++17
3 ms
956 KB
Wrong Answer