# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558646 | groshi | Secret (JOI14_secret) | C++17 | 497 ms | 8316 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |