#include "secret.h"
#include <bits/stdc++.h>
int val[1005][1005];
int a[1005];
void get(int l, int r){
if(l > r)
return;
if(l == r){
val[l][l] = a[l];
return;
}
int m1 = (l + r) >> 1;
int m2 = m1 + 1;
val[m1][m1] = a[m1];
val[m2][m2] = a[m2];
for(int i = m1 - 1; i >= l; i--){
val[i][m1] = val[m1][i] = Secret(val[i + 1][m1], a[i]);
}
for(int i = m2 + 1; i <= r; i++){
val[i][m2] = val[m2][i] = Secret(val[i - 1][m2], a[i]);
}
get(l, m1 - 1);
get(m2 + 1, r);
}
void Init(int N, int A[]){
memset(val, -1, sizeof val);
for(int i = 0; i < N; i++)
a[i] = A[i];
get(0, N - 1);
}
int Query(int L, int R) {
if(val[L][R] != -1)
return val[L][R];
for(int i = L; i < R; i++){
if(val[L][i] != -1 && val[i + 1][R] != -1)
return Secret(val[L][i], val[i + 1][R]);
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
165 ms |
6396 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
168 ms |
6392 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
168 ms |
6352 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
609 ms |
8312 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
595 ms |
8440 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184. |
6 |
Incorrect |
588 ms |
8440 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192. |
7 |
Incorrect |
592 ms |
8260 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
592 ms |
8320 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
607 ms |
8312 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
595 ms |
8336 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |