#include "secret.h"
#include<bits/stdc++.h>
#define N 1010
#define LOGN 11
using namespace std;
int n;
int v[N];
int lt[N][LOGN], rt[N][LOGN];
void prep(int l, int r, int con){
if(l == r) return;
int mid = (l+r)/2;
lt[mid][con] = v[mid];
rt[mid+1][con] = v[mid+1];
for(int i = mid-1;i >= l;i--){
lt[i][con] = Secret(v[i], lt[i+1][con]);
}
for(int i = mid+2;i <= r;i++){
rt[i][con] = Secret(rt[i-1][con], v[i]);
}
prep(l, mid, con+1);
prep(mid+1, r, con+1);
return;
}
int query(int l, int r, int tl = 0, int tr = n-1, int con = 0){
if(tl == tr) return v[tl];
int mid = (tl+tr)/2;
if(l <= mid and mid < r) return Secret(lt[l][con], rt[r][con]);
if(r <= mid) return query(l, r, tl, mid, con+1);
// else return query(l, )
return query(l, r, mid+1, tr, con);
}
void Init(int NN, int A[]) {
n = NN;
for(int i = 0;i < n;i++) v[i] = A[i];
prep(0, n-1, 0);
// Secret(0, 1000000000);
}
int Query(int L, int R) {
return query(L, R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
100 ms |
2648 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 576149945. |
2 |
Incorrect |
102 ms |
2812 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 466323528. |
3 |
Incorrect |
100 ms |
2808 KB |
Wrong Answer: Query(334, 369) - expected : 363022362, actual : 16889894. |
4 |
Incorrect |
376 ms |
4432 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : 323666462. |
5 |
Incorrect |
376 ms |
4356 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 212882718. |
6 |
Incorrect |
376 ms |
4828 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 537927681. |
7 |
Correct |
380 ms |
4404 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
380 ms |
4348 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
380 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
378 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |