# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
504168 | Deepesson | Secret (JOI14_secret) | C++17 | 440 ms | 16248 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>
#define MAX 1005
#include "secret.h"
int array[MAX];
int n;
int left[MAX*4][MAX],right[MAX*4][MAX];
int resp=0;
void acessa(int l,int r,int la=0,int ra=n-1,int pos=1){
if(r<la||ra<l)return;
int m = (la+ra)/2;
if(l<=m&&r>=m){
int posl=l-la;
int posr=r-(m+1);
int esq=left[pos][posl];
if(posr>=0)esq=Secret(esq,right[pos][posr]);
resp=esq;
return;
}
acessa(l,r,la,m,pos*2);
acessa(l,r,m+1,ra,(pos*2)+1);
}
void prep(int la=0,int ra=n-1,int pos=1){
int m = (la+ra)/2;
{
int ado=array[m];
for(int i=m;i!=la-1;--i){
int cord = i-la;
if(i!=m){
ado=Secret(array[i],ado);
}
left[pos][cord]=ado;
}
}
{
int ado=array[m+1];
for(int i=m+1;i!=ra+1;++i){
int cord = i-(m+1);
if(i!=m+1){
ado=Secret(ado,array[i]);
}
right[pos][cord]=ado;
}
}
if(la==ra)return;
prep(la,m,pos*2);
prep(m+1,ra,(pos*2)+1);
}
void Init(int N, int A[]){
n=N;
for(int i=0;i!=N;++i)array[i]=A[i];
prep();
}
int Query(int L, int R){
acessa(L,R);
return resp;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |