# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
803755 | 8pete8 | Secret (JOI14_secret) | C++14 | 398 ms | 4348 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"
using namespace std;
const int mxn=1e3;
int ans[11][mxn+10];
int v[mxn+10],mask[mxn+10];
void solve(int l,int r,int lev){
if(l==r)return;
int m=(r+l)/2;
ans[lev][m]=v[m];
for(int i=m-1;i>=l;i--)ans[lev][i]=Secret(v[i],ans[lev][i+1]);
ans[lev][m+1]=v[m+1];
for(int i=m+2;i<=r;i++)ans[lev][i]=Secret(ans[lev][i-1],v[i]);
for(int i=m+1;i<=r;i++)mask[i]^=(1ll<<lev);
solve(l,m,lev+1);
solve(m+1,r,lev+1);
}
void Init(int N,int A[]){
for(int i=0;i<N;i++)v[i]=A[i];
solve(0,N-1,0);
}
int Query(int L,int R){
if(L==R)return v[L];
int b=__builtin_ctz(mask[L]^mask[R]);
return Secret(ans[b][L],ans[b][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |