# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167196 | workharder | 비밀 (JOI14_secret) | C++14 | 632 ms | 8412 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;
const int MAXN=1005;
int arr[MAXN],simpan[MAXN][MAXN],n;
void build(int L,int R){
if(L==R){
simpan[L][R]=arr[L];
return;
}
int mid=(L+R)/2;
int now=arr[mid];
for(int i=mid-1;i>=L;i--){
simpan[i][mid]=Secret(arr[i],now);
now=simpan[i][mid];
}
now=arr[mid+1];
for(int i=mid+2;i<=R;i++){
simpan[mid+1][i]=Secret(now,arr[i]);
now=simpan[mid+1][i];
}
build(L,mid);
build(mid+1,R);
}
void Init(int N, int A[]) {
for(int i=1;i<=N;i++)arr[i]=A[i-1];
build(1,N);
n=N;
}
int tanya(int x,int y,int L,int R){
if(L==R){
return simpan[L][R];
}
int mid=(L+R)/2;
if(y<=mid){ // masuk kiri semua
return tanya(x,y,L,mid);
}
if(x>=mid+1){
return tanya(x,y,mid+1,R);
}
return Secret(simpan[x][mid],simpan[mid+1][y]);
}
int Query(int L,int R){
L++;R++;
return tanya(L,R,1,n);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |