# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338632 | amunduzbaev | XOR (IZhO12_xor) | C++14 | 144 ms | 22380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/** made by amunduzbaev **/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
const int N = 250005 ;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int n, m, k, ans, a[N];
int tree[N*30][2], node, sub[N*30];
void sett(int x, int ind){
int now = 0;
for(int i=29;i>=0;i--){
int bit = (x>>i)&1;
if(tree[now][bit]) now = tree[now][bit];
else{
tree[now][bit] = ++node;
now = node;
sub[now] = n+1;
}
sub[now] = min(sub[now], ind);
}
}
int get(int i, int x, int now, int cur){
if(cur >= k) return sub[now];
if(i<0 || cur + (1<<(i+1))-1 < k) return n+1;
int bit = (x>>i)&1, res = n+1;
for(int j=0;j<2;j++)
if(tree[now][j]) res = min(res, get(i-1, x, tree[now][j], (cur + (j != bit ? (1<<i) : 0))));
return res;
}
void solve(){
fastios
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
a[i] ^= a[i-1];
}
int l = 1, r = 1;
for(int i=1;i<=n;i++){
sett(a[i-1], i);
int lx = get(29, a[i], 0, 0);
if(i - lx > r - l) r = i, l = lx;
}
cout<<l<<" "<<r-l+1<<endl;
return;
}
int main(){
fastios
int t = 1;
if(t) solve();
else {
cin>>t;
while (t--) solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |