# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294360 | fucking_do_it | Secret (JOI14_secret) | C++14 | 516 ms | 8696 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];
void build(int l,int 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++;
if(x == y)return a[x];
int l = 1,r = n;
while(l != r){
if(x <= mid && y>= mid+1)
return Secret(dp[x][mid],dp[mid+1][y]);
if(x>mid)
l = mid+1;
else
r = mid;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |