#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int _N = 1e3 + 1;
int RR[_N][_N];// right[i][j] = query(j, i)
int LL[_N][_N]; // left[i][j] = query(i, j)
vector<int> temp;
int a[_N];
int n;
void build(int l,int r){
if(l + 1 < r){
int mid = (l + r + 1)/2;
assert(mid < r && l <= mid);
temp.push_back(mid);
RR[mid + 1][mid] = a[mid + 1];
for(int i = mid + 2;i<=r;i++){
RR[i][mid] = Secret(RR[i - 1][mid], a[i]);
}
LL[mid][mid] = a[mid];
for(int i = mid - 1;i>=0;i--){
LL[i][mid] = Secret(a[i], LL[i + 1][mid]);
}
build(l, mid);
build(mid, r);
}
}
void Init(int N, int A[]) {
for(int i = 0;i<N;i++)
a[i] = A[i];
build(1, N - 1);
}
int Query(int L, int R) {
if(L == R){
return a[L];
}
else if(L + 1 == R)
return Secret(a[L], a[R]);
else{
for(auto e : temp){
if(L <= e && e < R)return Secret(LL[L][e], RR[R][e]);
}
assert(false);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
253 ms |
6344 KB |
Output isn't correct - number of calls to Secret by Init = 131565, maximum number of calls to Secret by Query = 1 |
2 |
Partially correct |
230 ms |
6328 KB |
Output isn't correct - number of calls to Secret by Init = 132082, maximum number of calls to Secret by Query = 1 |
3 |
Partially correct |
247 ms |
6408 KB |
Output isn't correct - number of calls to Secret by Init = 132600, maximum number of calls to Secret by Query = 1 |
4 |
Partially correct |
880 ms |
12088 KB |
Output isn't correct - number of calls to Secret by Init = 501416, maximum number of calls to Secret by Query = 1 |
5 |
Partially correct |
874 ms |
12076 KB |
Output isn't correct - number of calls to Secret by Init = 502420, maximum number of calls to Secret by Query = 1 |
6 |
Runtime error |
911 ms |
24336 KB |
Execution killed with signal 6 |
7 |
Partially correct |
878 ms |
12116 KB |
Output isn't correct - number of calls to Secret by Init = 502420, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
884 ms |
12016 KB |
Output isn't correct - number of calls to Secret by Init = 502420, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
860 ms |
12016 KB |
Output isn't correct - number of calls to Secret by Init = 502420, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
871 ms |
12020 KB |
Output isn't correct - number of calls to Secret by Init = 502420, maximum number of calls to Secret by Query = 1 |