#include "secret.h"
#include <vector>
using namespace std;
const int maxD = 10;
vector<int> toright [maxD], toleft [maxD];
int *CA;
void Init(int N, int A[]) {
CA = A;
for (int rz = 0; rz < maxD; ++rz) {
toright[rz].resize(N);
toleft[rz].resize(N);
}
for (int k = 0; k < maxD; k++){
for (int cen = 1 << k; cen < N; cen += 1 << (k+1)) {
toright[k][cen - 1] = A[cen - 1];
for (int lpop = cen - 2; lpop >= cen - (1 << k); --lpop) {
toright[k][lpop] = Secret(A[lpop], toright[k][lpop + 1]);
}
toleft[k][cen] = A[cen];
for (int rpop = cen + 1; rpop < cen + (1 << k); ++rpop) {
toleft[k][rpop] = Secret(toleft[k][rpop - 1], A[rpop]);
}
}
}
}
int log2C(int n){
int res = 0;
while (n >> 1){
n >>= 1;
res++;
}
return res;
}
int Query(int L, int R) {
if (L == R) return CA[L];
int st = log2C(L ^ R);
return Secret(toright[st][L], toleft[st][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
2376 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
106 ms |
2472 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Runtime error |
109 ms |
4776 KB |
Execution killed with signal 6 |
4 |
Runtime error |
379 ms |
8712 KB |
Execution killed with signal 6 |
5 |
Runtime error |
376 ms |
8724 KB |
Execution killed with signal 6 |
6 |
Runtime error |
378 ms |
8760 KB |
Execution killed with signal 6 |
7 |
Runtime error |
377 ms |
8676 KB |
Execution killed with signal 6 |
8 |
Runtime error |
381 ms |
8704 KB |
Execution killed with signal 6 |
9 |
Runtime error |
378 ms |
8708 KB |
Execution killed with signal 6 |
10 |
Runtime error |
379 ms |
8700 KB |
Execution killed with signal 6 |