#include "secret.h"
#include <iostream>
using namespace std;
const int N=1001,LG=8;
int st[N][LG];
void Init(int N, int A[]) {
for(int j=0;j<N;j++) st[j][0]=A[j];
for(int j=1;j<LG;j++)
{
for(int i=0;i+(1<<j)<=N;i++)
{
st[i][j]=Secret(st[i][j-1],st[i+(1<<(j-1))][j-1]);
}
}
}
int Query(int L, int R) {
int ans=1e9+7;
// cout<<"cur "<<L<<' '<<R<<endl;
for(int j=LG-1;j>=0;j--)
{
while((1<<j)<=R-L+1)
{
// cout<<L<<' '<<j<<' '<<ans<<' '<<st[L][j]<<endl;
if(ans==1e9+7)ans=st[L][j];
else ans=Secret(ans,st[L][j]);
L+=(1<<j);
}
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |