#include "secret.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=1e3+10;
const int L=13;
ll jj[N][L];
int t[N],n;
void dc(int a,int b,int x){
int sr=(a+b)>>1;
jj[sr][x]=t[sr];
if(a==b) return;
for(int i=sr-1;i>=a;i--) jj[i][x]=Secret(t[i],jj[i+1][x]);
jj[sr+1][x]=t[sr+1];
for(int i=sr+2;i<=b;i++) jj[i][x]=Secret(jj[i-1][x],t[i]);
dc(a,sr,x+1),dc(sr+1,b,x+1);
}
pair<int,int> zn(int a,int b,int p=1,int k=n,int x=1){
int sr=(p+k)>>1;
if(a<=sr and b>=sr) return {x,sr};
if(a<=sr) return zn(a,b,p,sr,x+1);
return zn(a,b,sr+1,k,x+1);
}
void Init(int NN,int A[]){
n=NN;
for(int i=1;i<=n;i++) t[i]=A[i-1];
dc(1,n,1);
}
int Query(int a,int b){
a++,b++;
if(a==b) return t[a];
pair<int,int> curr=zn(a,b);
if(b==curr.se) return jj[a][curr.fi];
return Secret(jj[a][curr.fi],jj[b][curr.fi]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
2380 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
126 ms |
2388 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
123 ms |
2428 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
441 ms |
4296 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
441 ms |
4312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
447 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
451 ms |
4380 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
440 ms |
4508 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
442 ms |
4540 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
435 ms |
4288 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |