#include "secret.h"
#include <bits/stdc++.h>
#define MAXN 1007
using namespace std;
int val[MAXN][MAXN],a[MAXN],n;
void rek(int l,int r)
{
int s=(l+r)/2;
for(int i=s-1;i>=l;i--) val[i][s]=Secret(a[i],val[i+1][s]);
for(int i=s+2;i<=r;i++) val[s+1][i]=Secret(val[s+1][i-1],a[i]);
if(l==r) return;
rek(l,s);
rek(s+1,r);
}
void Init(int N, int A[])
{
n=N;
for(int i=0;i<n;i++) val[i][i]=a[i]=A[i];
rek(0,n-1);
}
int ans(int l,int r,int lt,int rt)
{
if(l==r) return a[l];
int s=(l+r)/2;
if(lt<=s && rt>s) return Secret(val[lt][s],val[s+1][rt]);
if(rt<=s) return ans(l,s,lt,rt);
return ans(s+1,r,lt,rt);
}
int Query(int L, int R) {return ans(0,n-1,L,R);}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
177 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
175 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
176 ms |
4808 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
666 ms |
8772 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
667 ms |
9092 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
617 ms |
9092 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
661 ms |
9120 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
621 ms |
9200 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
644 ms |
9340 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
615 ms |
9480 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |