Submission #1350155

#TimeUsernameProblemLanguageResultExecution timeMemory
1350155bakhtiyarnXOR (IZhO12_xor)C++20
0 / 100
1 ms2632 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int inf = 1e18;
const int N = 3e5+5;
int a[N];
int l[N*30], r[N*30], mn[N*30], C = 1;
int n, k;

void add(int x, int i){
  int u = 0;
  for(int b=30; b>=0; b--){
    bool is1 = (1ll<<b)&x;
    if(is1) {
      if(!r[u]) r[u] = C++;
      u = r[u];
    }
    else {
      if(!l[u]) l[u] = C++;
      u = l[u];
    }
    mn[u] = min(mn[u], i);
  }
}

int getans(int x){
  int u = 0, ans = 1e18; bool fir = false;
  for(int b=30; b>=0; b--){
    if(fir and !u) break;
    bool is1 = (1ll<<b)&x;
    bool is2 = (1ll<<b)&k;
    if(is1 and is2) u = l[u];
    else if(is1) ans = min(ans, mn[l[u]]), u = r[u];
    else if(is2) u = r[u];
    else ans = min(ans, mn[r[u]]), u = l[u];
    fir = true;
  }
  return ans;
}

// for(int i=1; i<=n; i++) 
void solve(){
  cin >> n >> k;
  for(int i=1; i<=n; i++) cin >> a[i], a[i] ^= a[i-1];
  if(!k){
    cout << 1 << " " << n; 
    return;
  }
  for(int i=0; i<N; i++) mn[i] = 1e18;
  add(0, 0);
  
  array<int, 2> ans = {1, 1};
  for(int i=1; i<=n; i++) {
    int l = getans(a[i]);
    
    ans = max(ans, {i-l, -l-1});
    
    add(a[i], i);
  }
  cout << -ans[1] << " " << ans[0];
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...