# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
682126 | NK_ | 비밀 (JOI14_secret) | C++17 | 417 ms | 4332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define nl '\n'
const int nax = 1025;
const int kax = 32 - __builtin_clz(nax);
int stor[nax][kax];
int N, M;
vector<int> A;
int comb(int a, int b) {
if (a == -1) return b;
if (b == -1) return a;
return Secret(a, b);
}
void fill(int l, int r, int ind) {
if (ind < 0) return;
int m = (l+r)/2, cur;
// cout << l << " " << m << " " << r << " (" << ind << ")" << endl;
stor[m-1][ind] = cur = A[m-1];
for(int i = m-2; i >= l; i--) stor[i][ind] = cur = comb(A[i], cur);
stor[m][ind] = cur = A[m];
for(int i = m+1; i < r; i++) stor[i][ind] = cur = comb(cur, A[i]);
fill(l, m, ind-1); fill(m, r, ind-1);
}
void Init(int _N, int _A[]) {
N = _N;
M = 1; while((1<<M) < N) ++M;
A = vector<int>((1<<M), -1);
for(int i = 0; i < N; i++) A[i] = _A[i];
fill(0, (1<<M), M-1);
// cerr << "DONE" << endl;
}
int Query(int L, int R) {
if (L == R) return A[L];
int t = 31 - __builtin_clz(L ^ R);
return comb(stor[L][t], stor[R][t]);
};
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |