#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
const int maxlvl = 10;
int n;
int* V;
int DVC[maxlvl][maxn];
void create(int lvl, int l, int r, int A[]) {
//cout << lvl << ' ' << l << ' ' << r << endl;
if (l == r) {
DVC[lvl][l] = A[l];
return;
}
int m = (l + r) >> 1;
// left side
DVC[lvl][m] = A[m];
for (int i = m - 1; i >= l; i--) DVC[lvl][i] = Secret(A[i], DVC[lvl][i + 1]);
// right side
DVC[lvl][m + 1] = A[m + 1];
for (int i = m + 2; i <= r; i++) DVC[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 DVC[lvl][L];
int m = (l + r) >> 1;
//cout << lvl << ' ' << l << ' ' << r << ' ' << m << ' ' << L << ' ' << R << endl;
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(DVC[lvl][L], DVC[lvl][R]);
}
void Init(int N, int A[]) {
V = A;
n = N;
create(0, 0, n - 1, A);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < n; j++) {
//cout << DVC[i][j] << ' ';
}
//cout << endl;
}
}
int Query(int L, int R) {
//cout << "-----------------" << endl;
//cout << L << ' ' << R << endl;
return get(0, 0, n - 1, L, R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
2424 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
126 ms |
2408 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
125 ms |
2400 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Runtime error |
438 ms |
8544 KB |
Execution killed with signal 11 |
5 |
Runtime error |
439 ms |
8708 KB |
Execution killed with signal 11 |
6 |
Runtime error |
430 ms |
8656 KB |
Execution killed with signal 11 |
7 |
Runtime error |
445 ms |
8496 KB |
Execution killed with signal 11 |
8 |
Runtime error |
431 ms |
8540 KB |
Execution killed with signal 11 |
9 |
Runtime error |
437 ms |
8552 KB |
Execution killed with signal 11 |
10 |
Runtime error |
453 ms |
8560 KB |
Execution killed with signal 11 |