#include <bits/stdc++.h>
using namespace std;
#include "secret.h"
typedef long double ld;
typedef long long ll;
ll niz[1005];
ll res[1005][1005];
int n;
int fajnd(int l, int r, int tl, int tr){
if(r > l) return -1;
if(l > tr || tl > r) return -1;
int mid = (l+r)/2;
if(l <= tl && tr <= r && tl <= mid && r >= mid+1) return mid;
return max(fajnd(l, mid, tl, tr), fajnd(mid+1, r, tl, tr));
}
void process(int l, int r){
int mid = (l+r)/2;
if(l == r) return;
res[mid][mid] = niz[mid];
res[mid+1][mid+1] = niz[mid+1];
for(ll j=mid-1; j>=l; j--){
res[j][mid] = Secret(niz[j], res[j+1][mid]);
}
for(ll j=mid+2; j<=r; j++){
res[mid+1][j] = Secret(res[mid+1][j-1], niz[j]);
}
process(l, mid);
process(mid+1, r);
}
void Init(int N, int A[]){
n = N;
for(ll i=0; i<N; i++) niz[i] = A[i];
process(0, n-1);
}
int Query(int L, int R){
if(L == R) return niz[L];
if(R == L+1) return Secret(niz[L], niz[R]);
int i = fajnd(0, n-1, L, R);
return Secret(res[L][i], res[i+1][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
162 ms |
4856 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 536870912. |
2 |
Incorrect |
167 ms |
4856 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 0. |
3 |
Incorrect |
165 ms |
4784 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 536870912. |
4 |
Incorrect |
600 ms |
9596 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 536870912. |
5 |
Incorrect |
597 ms |
9628 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 536870912. |
6 |
Incorrect |
598 ms |
9720 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 536870912. |
7 |
Incorrect |
605 ms |
9592 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0. |
8 |
Incorrect |
598 ms |
9772 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 536870912. |
9 |
Incorrect |
597 ms |
9780 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 0. |
10 |
Incorrect |
600 ms |
9692 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 0. |