# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043402 |
2024-08-04T09:07:04 Z |
BF001 |
Secret (JOI14_secret) |
C++17 |
|
0 ms |
0 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
const int maxlvl = 15;
int n;
int rt[maxlvl][maxn], lf[maxlvl][maxn];
void create(int lvl, int l, int r, int A[]) {
if (l == r) {
lf[lvl][l] = A[l];
return;
}
int m = (l + r) >> 1;
// left side
lf[lvl][m] = A[m];
for (int i = m - 1; i >= l; i--) lf[lvl][i] = Secret(A[i], DVC[lvl][i + 1]);
// right side
rt[lvl][m + 1] = A[m + 1];
for (int i = m + 2; i <= r; i++) rt[lvl][i] = Secret(DVC[lvl][i - 1], A[i]);
create(lvl + 1, l, m, A);
create(lvl + 1, m + 1, r, A);
}
int get(int lvl, int l, int r, int L, int R) {
if (l == r) return lf[lvl][L];
int m = (l + r) >> 1;
if (R <= m) return get(lvl + 1, l, m, L, R);
if (L >= m+1) return get(lvl + 1, m+1, r, L, R);
return Secret(lf[lvl][L], rt[lvl][R]);
}
void Init(int N, int A[]) {
n = N;
create(0, 0, n - 1, A);
}
int Query(int L, int R) {
return get(0, 0, n - 1, L, R);
}
Compilation message
secret.cpp: In function 'void create(int, int, int, int*)':
secret.cpp:20:64: error: 'DVC' was not declared in this scope
20 | for (int i = m - 1; i >= l; i--) lf[lvl][i] = Secret(A[i], DVC[lvl][i + 1]);
| ^~~
secret.cpp:23:58: error: 'DVC' was not declared in this scope
23 | for (int i = m + 2; i <= r; i++) rt[lvl][i] = Secret(DVC[lvl][i - 1], A[i]);
| ^~~