# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
558646 |
2022-05-07T19:49:34 Z |
groshi |
Secret (JOI14_secret) |
C++17 |
|
497 ms |
8316 KB |
#include<iostream>
#include "secret.h"
using namespace std;
int n;
int t[100000];
int wyn[1010][1010];
/*long long Secret(int x,int y)
{
return x+y;
}*/
void rob(int l,int r)
{
int sre=(l+r)/2;
wyn[sre][sre]=t[sre];
wyn[sre+1][sre+1]=t[sre+1];
for(int i=sre+2;i<=r;i++)
wyn[sre+1][i]=Secret(wyn[sre+1][i-1],t[i]);
for(int i=sre-1;i>=l;i--)
wyn[i][sre]=Secret(t[i],wyn[i+1][sre]);
if(sre>l)
rob(l,sre);
if(sre+1<r)
rob(sre+1,r);
}
int zap(int x1,int y1,int l,int r)
{
int mid=(x1+y1)/2;
if(x1==y1)
return wyn[x1][y1];
if(l<=mid && mid<r)
return Secret(wyn[l][mid],wyn[mid+1][r]);
if(l>mid)
return zap(mid+1,y1,l,r);
else return zap(x1,mid,l,r);
}
void Init(int N,int A[])
{
n=N;
for(int i=0;i<n;i++)
t[i]=A[i];
rob(0,n-1);
}
int Query(int l,int r)
{
return zap(0,n-1,l,r);
}
/*int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int t[5]={1,4,2,3,6};
Init(5,t);
cout<<Query(0,4)<<"\n";
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
127 ms |
4412 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
132 ms |
4392 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
472 ms |
8316 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
497 ms |
8236 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
449 ms |
8192 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
482 ms |
8180 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
486 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
461 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
462 ms |
8296 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |