Submission #111513

#TimeUsernameProblemLanguageResultExecution timeMemory
111513vexSecret (JOI14_secret)C++14
100 / 100
578 ms8520 KiB
#include <bits/stdc++.h> #include <secret.h> #define maxn 1005 #define pii pair<int,int> using namespace std; int len; int niz[maxn]; vector<pii>v; int rez[maxn][maxn]; void napravi(int l,int r,int a[]) { int duz=r-l+1; if(duz<=1)return; int mid=(l+r)/2; v.push_back({l,r}); rez[mid][mid+1]=a[mid+1]; rez[mid][mid]=a[mid]; for(int i=mid+2;i<=r;i++)rez[mid][i]=Secret(rez[mid][i-1],a[i]); for(int i=mid-1;i>=l;i--)rez[i][mid]=Secret(a[i],rez[i+1][mid]); napravi(l,mid-1,a); napravi(mid+1,r,a); } void Init(int n,int a[]) { len=n; for(int i=0;i<len;i++)niz[i]=a[i]; napravi(0,n-1,a); } int Query(int l,int r) { if(l==r)return niz[l]; for(auto x:v) { int ll=x.first; int rr=x.second; int mid=(ll+rr)/2; if(ll<=l && l<=mid && mid<=r && r<=rr) { if(r==mid)return rez[l][mid]; return Secret(rez[l][mid],rez[mid][r]); } } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...