# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957463 | FEDIKUS | Secret (JOI14_secret) | C++17 | 391 ms | 4772 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;
map<pair<int,int>,int> prec;
int *a;
int n;
void dc(int l,int r){
if(l==r){
prec[{l,l}]=a[l];
return;
}
int mid=l+(r-l)/2;
int tren=a[mid+1];
prec[{mid+1,mid+1}]=tren;
for(int i=mid+2;i<=r;i++){
tren=Secret(tren,a[i]);
prec[{mid+1,i}]=tren;
}
tren=a[mid];
for(int i=mid-1;i>=l;i--){
tren=Secret(a[i],tren);
prec[{i,mid}]=tren;
}
dc(l,mid);
dc(mid+1,r);
}
void Init(int nn, int aa[]) {
n=nn;
a=aa;
dc(0,n-1);
}
int result(int tl,int tr,int l=0,int r=n-1){
int mid=l+(r-l)/2;
if(l<=mid && mid<r){
return Secret(prec[{tl,mid}],prec[{mid+1,tr}]);
}else if(r<=mid){
return result(tl,tr,l,mid);
}else return result(tl,tr,mid+1,r);
}
int Query(int l, int r) {
if(l==r) return a[l];
return result(l,r);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |