# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
536269 | michao | 비밀 (JOI14_secret) | C++14 | 514 ms | 4512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 pref[MAX][STALA];
int suf[MAX][STALA];
int n;
int a[MAX];
void rec1(int l,int r,int dep){
if (l>r)return;
int mid=(l+r)>>1;
pref[mid][dep]=a[mid];
suf[mid+1][dep]=a[mid+1];
for (int i=mid-1;i>=l;i--){
pref[i][dep]=Secret(a[i],pref[i+1][dep]);
}
for (int i=mid+2;i<=r;i++){
suf[i][dep]=Secret(suf[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(pref[mid][dep],suf[mid+1][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... |