#include "secret.h"
int v[1007][1007],a[1007],n;void t(int l,int r){int s=(l+r)/2;for(int i=s-1;i>=l;i--)v[i][s]=Secret(a[i],v[i+1][s]);for(int i=s+2;i<=r;i++)v[s+1][i]=Secret(v[s+1][i-1],a[i]);if(l==r)return;t(l,s);t(s+1,r);}void Init(int N,int A[]){n=N;for(int i=0;i<n;i++)v[i][i]=a[i]=A[i];t(0,n-1);}int b(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(v[lt][s],v[s+1][rt]);if(rt<=s)return b(l,s,lt,rt);return b(s+1,r,lt,rt);}int Query(int L, int R){return b(0,n-1,L,R);}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
177 ms |
4580 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
182 ms |
4704 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
637 ms |
8456 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
595 ms |
8508 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
593 ms |
8520 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
609 ms |
8520 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
612 ms |
8648 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
602 ms |
8648 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
607 ms |
8648 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |