#include "secret.h"
#include <bits/stdc++.h>
const int N = 1e3;
int val[N][N];
int a[N];
void rec(int l, int r){
if(l > r)
return;
if(l == r){
val[l][l] = a[l];
return;
}
int mid = (l + r) >> 1;
// (l, mid), (l + 1, mid), ..., (mid, mid)
int pre = a[mid];
for(int i = mid; i >= l; i--){
if(i < mid)pre = Secret(pre, a[i]);
val[i][mid] = pre;
}
pre = a[mid + 1];
for(int i = mid + 1; i <= r; i++){
if(i > mid + 1)pre = Secret(pre, a[i]);
val[mid + 1][i] = pre;
}
rec(l, mid - 1);
rec(mid + 2, r);
}
void Init(int n, int A[]) {
memset(val, -1, sizeof(val));
for(int i = 0; i < n; i++){
a[i] = val[i][i] = A[i];
}
rec(0, n - 1);
}
int Query(int L, int R) {
if(L == R)
return val[L][L];
for(int i = L; i + 1 <= R; i++){
if(val[L][i] != -1 && val[i + 1][R] != -1)
return Secret(val[L][i], val[i + 1][R]);
}
if(val[L][R] != -1)
return val[L][R];
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
115 ms |
6260 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
115 ms |
6228 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
117 ms |
6228 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
426 ms |
8192 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
431 ms |
8256 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184. |
6 |
Incorrect |
424 ms |
8120 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192. |
7 |
Incorrect |
419 ms |
8120 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
421 ms |
8080 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
420 ms |
8208 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
423 ms |
8068 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |