# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532506 | Evang | Secret (JOI14_secret) | C++17 | 447 ms | 4524 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 pb push_back
using namespace std;
static const int N = 1005;
static int n, a[N];
vector<int> lef[N], rig[N];
void evan(int l, int r){
if(l==r)
return;
int m = (l+r)/2;
lef[m].pb(a[m]);
for(int i = m-1; i >= l; --i)
lef[m].pb(Secret(a[i], lef[m].back()));
rig[m+1].pb(a[m+1]);
for(int i = m+2; i <= r; ++i)
rig[m+1].pb(Secret(rig[m+1].back(), a[i]));
evan(l, m);
evan(m+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; ++i)
a[i] = A[i];
evan(0, n-1);
}
int Query(int l, int r) {
int il = 0, ir = n-1;
while(il<ir){
int m = (il+ir)/2;
if(l<=m && m < r)
return Secret(lef[m][m-l], rig[m+1][r-m-1]);
if(m < l)
il = m+1;
else
ir = m;
}
return a[r];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |