#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1024;
int n,a[maxn];
int pref[maxn][16],suff[maxn][16];
int query(int l, int r, int lvl, int L, int R)
{
if(l>r) return 0;
int mid = (l+r)/2;
if(L<=mid&&mid<=R)
{
int chis = pref[L][lvl];
if(R!=mid) chis = Secret(chis,suff[R][lvl]);
return chis;
}
if(R<mid) return query(l,mid-1,lvl+1,L,R);
return query(mid+1,r,lvl+1,L,R);
}
int Query(int L, int R)
{
L++;
R++;
int ans = query(1,n,1,L,R);
return ans;
}
void divide(int l, int r, int lvl)
{
int mid = (l+r)/2;
pref[mid][lvl] = a[mid];
for(int i=mid-1;i>=l;i--) pref[i][lvl] = Secret(a[i],pref[i+1][lvl]);
if(mid!=r) suff[mid+1][lvl] = a[mid+1];
for(int i=mid+2;i<=r;i++) suff[i][lvl] = Secret(suff[i-1][lvl],a[i]);
if(l==r) return;
divide(l,mid-1,lvl+1);
divide(mid+1,r,lvl+1);
}
void Init(int N, int A[])
{
n = N;
for(int i=1;i<=n;i++) a[i] = A[i-1];
divide(1,n,1);
}
/*int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
2900 KB |
Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1 |
2 |
Runtime error |
103 ms |
8016 KB |
Execution killed with signal 11 |
3 |
Runtime error |
103 ms |
8784 KB |
Execution killed with signal 11 |
4 |
Runtime error |
376 ms |
13024 KB |
Execution killed with signal 11 |
5 |
Runtime error |
377 ms |
12880 KB |
Execution killed with signal 11 |
6 |
Runtime error |
378 ms |
13060 KB |
Execution killed with signal 11 |
7 |
Runtime error |
376 ms |
12908 KB |
Execution killed with signal 11 |
8 |
Runtime error |
379 ms |
12976 KB |
Execution killed with signal 11 |
9 |
Runtime error |
375 ms |
12880 KB |
Execution killed with signal 11 |
10 |
Runtime error |
379 ms |
12972 KB |
Execution killed with signal 11 |