# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538901 | schiftyfive4 | Secret (JOI14_secret) | C++14 | 485 ms | 4444 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"
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=1e3+5;
const int STALA=30;
int t[MAX][STALA];
int n;
int a[MAX];
void rec1(int l,int r,int dep){
if (l>r)return;
int mid=(l+r)>>1;
t[mid][dep]=a[mid];
t[mid+1][dep]=a[mid+1];
for (int i=mid-1;i>=l;i--){
t[i][dep]=Secret(a[i],t[i+1][dep]);
}
for (int i=mid+2;i<=r;i++){
t[i][dep]=Secret(t[i-1][dep],a[i]);
}
if (l<r){
rec1(l,mid,dep+1);
rec1(mid+1,r,dep+1);
}
}
void Init(int N,int A[]){
n=N;
for (int i=0;i<n;i++)a[i]=A[i];
rec1(0,n-1,0);
}
int rec2(int l,int r,int L,int R,int dep){
int mid=(l+r)>>1;
if (L>mid)return rec2(mid+1,r,L,R,dep+1);
if (R<=mid)return rec2(l,mid,L,R,dep+1);
return Secret(t[L][dep],t[R][dep]);
}
int Query(int L,int R){
if (L==R)return a[L];
return rec2(0,n-1,L,R,0);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |