#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(LL[i + 1][mid], a[i]);
}
build(l, mid);
build(mid + 1, 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 |
Incorrect |
177 ms |
6304 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 536955102. |
2 |
Incorrect |
187 ms |
6412 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 747241792. |
3 |
Incorrect |
185 ms |
6408 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 688130334. |
4 |
Incorrect |
688 ms |
12020 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 391774777. |
5 |
Incorrect |
685 ms |
12136 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184. |
6 |
Incorrect |
677 ms |
12108 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192. |
7 |
Incorrect |
692 ms |
12040 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 657493000. |
8 |
Incorrect |
692 ms |
12080 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 764569728. |
9 |
Incorrect |
691 ms |
12032 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277877441. |
10 |
Incorrect |
699 ms |
12192 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 69725386. |