# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25344 | kajebiii | Secret (JOI14_secret) | C++14 | 633 ms | 19292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "secret.h"
#include <vector>
#include <stdio.h>
using namespace std;
const int MAX_N = 1e3 + 100;
const int ROOT_N = 32;
int Nr[MAX_N], W[MAX_N][MAX_N], Cnt;
int L[MAX_N][MAX_N], R[MAX_N][MAX_N];
void makeLR(int a, int b) {
if(a == b) return;
int m = (a+b) >> 1;
Cnt++;
for(int i=a; i<=m; i++) for(int j=m+1; j<=b; j++)
W[i][j] = Cnt;
L[Cnt][m] = Nr[m];
R[Cnt][m+1] = Nr[m+1];
for(int i=m-1; i>=a; i--) L[Cnt][i] = Secret(Nr[i], L[Cnt][i+1]);
for(int i=m+2; i<=b; i++) R[Cnt][i] = Secret(R[Cnt][i-1], Nr[i]);
makeLR(a, m);
makeLR(m+1, b);
}
int getQ(int a, int b) {
if(a == b) return Nr[a];
int w = W[a][b];
return Secret(L[w][a], R[w][b]);
}
void Init(int N, int A[]) {
for(int i=0; i<N; i++) Nr[i] = A[i];
makeLR(0, N-1);
}
int Query(int L, int R) {
return getQ(L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |