#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;
pair <int, int> fajnd(int l, int r, int tl, int tr){
if(r-l <= 1) return {l, r-l+1};
int mid = (l+r)/2;
if(tl <= mid && mid <= tr) return {mid, r-l+1};
pair <int, int> x = fajnd(l, mid, tl, tr);
pair <int, int> y = fajnd(mid+1, r, tl, tr);
if(x.second > y.second) return x;
return y;
}
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]);
pair <int, int> g = fajnd(0, n-1, L, R);
int i = g.first;
return Secret(res[L][i], res[i+1][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
164 ms |
4856 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042. |
2 |
Incorrect |
166 ms |
4908 KB |
Wrong Answer: Query(262, 383) - expected : 858891369, actual : 858890345. |
3 |
Incorrect |
163 ms |
4856 KB |
Wrong Answer: Query(64, 128) - expected : 469502, actual : 537340286. |
4 |
Incorrect |
598 ms |
9732 KB |
Wrong Answer: Query(571, 624) - expected : 309502044, actual : 309493852. |
5 |
Incorrect |
602 ms |
9744 KB |
Wrong Answer: Query(876, 890) - expected : 899551822, actual : 362418254. |
6 |
Incorrect |
609 ms |
9592 KB |
Wrong Answer: Query(747, 749) - expected : 244228265, actual : 143302825. |
7 |
Correct |
620 ms |
9740 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
623 ms |
9648 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
629 ms |
9868 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
609 ms |
9836 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |