# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294369 | fucking_do_it | Secret (JOI14_secret) | C++14 | 533 ms | 8440 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 "secret.h"
#include <bits/stdc++.h>
#define mid (l+r)/2
using namespace std;
const int inf = 1e3+9;
int n,a[inf],cnt;
int dp[inf][inf];
vector<pair<int,int> > ranges;
void build(int l,int r){
ranges.push_back(make_pair(l,r));
if(l == r)
return ;
for(int i=mid-1;i>=l;i--)
dp[i][mid] = Secret(a[i],dp[i+1][mid]);
for(int i = mid+2;i<=r;i++)
dp[mid+1][i] = Secret(dp[mid+1][i-1],a[i]);
build(l,mid);
build(mid+1,r);
}
void Init(int N, int A[]) {
n = N;
for(int i=1;i<=n;i++)
a[i] = A[i-1],dp[i][i] = a[i];
build(1,n);
assert(cnt<=8000);
}
int Query(int x, int y) {
x++,y++;
for(auto o:ranges){
int l = o.first,r = o.second;
if(!(x >= l && r >= y && mid >=x && mid <= y))
continue;
if(y == mid || x == mid+1)
return dp[x][y];
else
return Secret(dp[x][mid],dp[mid+1][y]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |