# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111513 | vex | Secret (JOI14_secret) | C++14 | 578 ms | 8520 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 <secret.h>
#define maxn 1005
#define pii pair<int,int>
using namespace std;
int len;
int niz[maxn];
vector<pii>v;
int rez[maxn][maxn];
void napravi(int l,int r,int a[])
{
int duz=r-l+1;
if(duz<=1)return;
int mid=(l+r)/2;
v.push_back({l,r});
rez[mid][mid+1]=a[mid+1];
rez[mid][mid]=a[mid];
for(int i=mid+2;i<=r;i++)rez[mid][i]=Secret(rez[mid][i-1],a[i]);
for(int i=mid-1;i>=l;i--)rez[i][mid]=Secret(a[i],rez[i+1][mid]);
napravi(l,mid-1,a);
napravi(mid+1,r,a);
}
void Init(int n,int a[])
{
len=n;
for(int i=0;i<len;i++)niz[i]=a[i];
napravi(0,n-1,a);
}
int Query(int l,int r)
{
if(l==r)return niz[l];
for(auto x:v)
{
int ll=x.first;
int rr=x.second;
int mid=(ll+rr)/2;
if(ll<=l && l<=mid && mid<=r && r<=rr)
{
if(r==mid)return rez[l][mid];
return Secret(rez[l][mid],rez[mid][r]);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |