# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881122 | alexdd | XOR (IZhO12_xor) | C++17 | 2025 ms | 151804 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.
#include<iostream>
#include<map>
using namespace std;
int n,x;
map<int,int> fr[30];
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>x;
int a,maxlun=0,pozmax=0,curlun,sump=0;
for(int i=1;i<=n;i++)
{
cin>>a;
sump ^= a;
a = sump;
///a ^ y == x
curlun = i + fr[0][(a^x)] - 300000;
if(fr[0][(a^x)]!=0 && curlun > maxlun)
{
maxlun = curlun;
pozmax=i;
}
int pref=0,prefx=0;
for(int j=29;j>=0;j--)
{
if(((1<<j)&a))
pref += (1<<j);
if(((1<<j)&x))
prefx += (1<<j);
if(((1<<j)&x)==0)
{
///pref ^ y == prefx + (1<<j)
curlun = i + fr[j][(pref^(prefx+(1<<j)))] - 300000;
if(fr[j][(pref^(prefx+(1<<j)))]!=0 && curlun > maxlun)
{
maxlun = curlun;
pozmax=i;
}
}
fr[j][pref] = max(fr[j][pref], -i + 300000);
}
}
cout<<pozmax-maxlun+1<<" "<<maxlun;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |