# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588931 | BT21tata | XOR (IZhO12_xor) | C++17 | 7 ms | 1620 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<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define setp fixed<<setprecision
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
const ll mod=(1ll<<31)-1;
const ld eps=1e-8;
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n, x, pr[250005], l[250005], r[250005], cur=1, pos[250005];
void add(int v, int num, int p, int bit)
{
pos[v]=min(p, pos[v]);
if(bit==-1) return;
if(num&(1<<bit))
{
if(!r[v]) r[v]=cur++;
add(r[v], num, p, bit-1);
}
else
{
if(!l[v]) l[v]=cur++;
add(l[v], num, p, bit-1);
}
}
int fnd(int v, int num, int bit)
{
if(!v) return MOD;
if(bit==-1) return pos[v];
if(x&(1<<bit))
{
if(num&(1<<bit))
return fnd(l[v], num, bit-1);
else
return fnd(r[v], num, bit-1);
}
else
{
return min(fnd(l[v], num, bit-1), fnd(r[v], num, bit-1));
}
}
int main()
{
SPEED;
cin>>n>>x;
for(int i=1; i<=n; i++)
{
int k; cin>>k;
pr[i]=pr[i-1]^k;
}
// pr[r]^pr[l-1]>=x
int ansl=MOD, sz=0;
memset(pos, 63, sizeof(pos));
for(int i=1; i<=n; i++)
{
add(1, pr[i], i, 30);
int e=fnd(1, pr[i], 30);
if(sz<i-e+1)
{
sz=i-e;
ansl=e+1;
}
}
cout<<ansl<<' '<<sz<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |