# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153488 | georgerapeanu | Secret (JOI14_secret) | C++11 | 588 ms | 4560 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"
using namespace std;
int stuff[20][1005];
int global_n;
void build(int stage,int st,int dr,int a[]){
if(st == dr){
stuff[stage][st] = a[st];
return ;
}
int mid = (st + dr) / 2;
stuff[stage][mid] = a[mid];
stuff[stage][mid + 1] = a[mid + 1];
for(int i = mid - 1;i >= st;i--){
stuff[stage][i] = Secret(a[i],stuff[stage][i + 1]);
}
for(int i = mid + 2;i <= dr;i++){
stuff[stage][i] = Secret(stuff[stage][i - 1],a[i]);
}
build(stage + 1,st,mid,a);
build(stage + 1,mid + 1,dr,a);
}
int query(int stage,int st,int dr,int l,int r){
int mid = (st + dr) / 2;
if(l <= mid && mid <= r){
if(r == mid){
return stuff[stage][l];
}
return Secret(stuff[stage][l],stuff[stage][r]);
}
else if(mid < l){
return query(stage + 1,mid + 1,dr,l,r);
}
else{
return query(stage + 1,st,mid,l,r);
}
}
void Init(int n, int a[]) {
global_n = n;
build(0,0,n - 1,a);
}
int Query(int l, int r) {
return query(0,0,global_n - 1,l,r);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |