# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
834412 | serifefedartar | Secret (JOI14_secret) | C++17 | 20079 ms | 6328 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>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 200005
int ranges[1005][1005];
int n;
void build(int l, int r, int A[]) {
if (l > r)
return ;
int mid = (l+r)/2;
ranges[mid][mid] = A[l];
for (int i = mid-1; i >= l; i--)
ranges[i][mid] = Secret(ranges[i+1][mid], A[i]);
for (int i = mid+1; i <= r; i++)
ranges[mid][i] = Secret(ranges[mid][i-1], A[i]);
build(l, mid, A);
build(mid+1, r, A);
}
void Init(int N, int A[]) {
build(0, N-1, A);
n = N;
}
int Query(int L, int R) {
int now_l = 0;
int now_r = n-1;
while (now_l <= now_r) {
int mid = (now_l+now_r)/2;
if (L == mid || R == mid)
return ranges[mid][R];
if (L > mid)
now_l = mid+1;
else if (R < mid)
now_r = mid-1;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |