# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
540754 | amin | Secret (JOI14_secret) | C++14 | 20054 ms | 4700 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 "secret.h"
#include<bits/stdc++.h>
using namespace std;
long n;
long u;
long a[130000];
map<pair<long,long>,long>m;
void build(long v,long tl,long tr)
{
if(tl==tr)
{
return ;
}
long tm=(tl+tr)/2;
long ans=tl;
for(long i=tl+1;i<=tm;i++)
{
ans=Secret(ans,a[i]);
m[{tl,i}]=ans;
}
ans=a[tm+1];
for(long i=tm+2;i<=tr;i++)
{
ans=Secret(ans,a[i]);
m[{i,tr}]=ans;
}
build(v*2,tl,tm);
build(v*2+1,tm+1,tr);
}
long get(long v,long tl,long tr,long l,long r)
{
long tm=(tl+tr)/2;
if(r<=tm)
{
return get(v*2,tl,tm,l,r);
}
if(l>tm)
{
return get(v*2+1,tm+1,tr,l,r);
}
long ans=Secret(m[{l,tm}],m[{tm+1,r}]);
return ans;
}
void Init(int N, int A[]) {
n=N;
for(long i=0;i<N;i++)
{
a[i]=A[i];
m[{a[i],a[i]}]=a[i];
}
build(1,0,n-1);
}
int Query(int L, int R) {
return get(1,0,n-1,L-1,R-1);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |