#include <iostream>
#include "secret.h"
using namespace std;
int st[4005],a[1005],n;
/*
int Secret(int X, int Y){
return X+2*(Y/2);
}*/
int qst(int nd,int l,int r,int a,int b){
//cout<<l<<" "<<r<<"\n";
if(a<=l&&r<=b)return st[nd];
int m=(l+r)/2;
if(a<=m&&l<=b){
if(a<=r&&m+1<=b){
return Secret(qst(2*nd,l,m,a,b),qst(2*nd+1,m+1,r,a,b));
}else return qst(2*nd,l,m,a,b);
}else return qst(2*nd+1,m+1,r,a,b);
}
int Query(int L, int R){
//cout<<"Query\n";
return qst(1,0,n-1,L,R);
}
int ist(int nd,int l,int r){
//cout<<l<<" "<<r<<"\n";
if(l==r)
return st[nd]=a[l];
int m=(l+r)/2;
return st[nd]=Secret(ist(2*nd,l,m),ist(2*nd+1,m+1,r));
}
void Init(int N, int A[]){
//cout<<"Init\n";
n=N;
for(int i=0;i<n;i++)a[i]=A[i];
ist(1,0,n-1);
return;
}
/*
int main(){
cin.tie(0);cout.tie(0);//ios_base::sync_with_stdio(0);
//int a=16,b[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
int a=8,b[8]={1,4,7,2,5,8,3,6};
Init(a,b);
cout<<Query(0,3)<<"\n";
cout<<Query(1,7)<<"\n";
cout<<Query(5,5)<<"\n";
cout<<Query(2,4)<<"\n";
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
145 ms |
2900 KB |
Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 13 |
2 |
Partially correct |
141 ms |
2812 KB |
Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14 |
3 |
Partially correct |
143 ms |
2652 KB |
Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 15 |
4 |
Partially correct |
422 ms |
4428 KB |
Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15 |
5 |
Partially correct |
419 ms |
4356 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15 |
6 |
Partially correct |
382 ms |
4388 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4 |
7 |
Partially correct |
440 ms |
4436 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
8 |
Partially correct |
438 ms |
4444 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
9 |
Partially correct |
441 ms |
4344 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
10 |
Partially correct |
438 ms |
4348 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |