# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
636538 | JooDdae | 비밀 (JOI14_secret) | C++17 | 424 ms | 4556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#define mid ((l+r) >> 1)
int n, a[1010];
vector<int> LL[4040], RR[4040];
void build(int node = 1, int l = 1, int r = n) {
if(l > r) return;
LL[node].push_back(a[mid]);
for(int i=mid-1;i>=l;i--) {
LL[node].push_back(Secret(a[i], LL[node].back()));
}
if(l == r) return;
RR[node].push_back(a[mid+1]);
for(int i=mid+2;i<=r;i++) {
RR[node].push_back(Secret(RR[node].back(), a[i]));
}
build(node*2, l, mid-1), build(node*2+1, mid+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i=1;i<=n;i++) a[i] = A[i-1];
build();
}
int find(int nl, int nr, int node = 1, int l = 1, int r = n) {
if(nl <= mid && mid <= nr) {
if(mid == nr) return LL[node][mid-nl];
return Secret(LL[node][mid-nl], RR[node][nr-mid-1]);
}
if(nr < mid) return find(nl, nr, node*2, l, mid-1);
return find(nl, nr, node*2+1, mid+1, r);
}
int Query(int L, int R) {
return find(L+1, R+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |