# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321633 | peuch | Secret (JOI14_secret) | C++17 | 20035 ms | 9836 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>
const int MAXN = 1010;
int n;
long long value[MAXN][MAXN];
long long v[MAXN];
void dc(int ini, int fim){
if(ini == fim) {
value[ini][ini] = v[ini];
return;
}
int mid = (ini + fim) >> 1;
dc(ini, mid);
dc(mid + 1, fim);
for(int i = mid - 1; i >= ini; i--)
value[i][mid] = Secret(value[i + 1][mid], v[i]);
for(int i = mid + 2; i <= fim; i++)
value[mid + 1][i] = Secret(value[mid + 1][i - 1], v[i]);
}
long long getVal(int ini, int fim, int l, int r){
int mid = (ini + fim) >> 1;
if(l <= mid && r > mid)
return Secret(value[l][mid], value[mid + 1][r]);
if(r <= mid)
return getVal(ini, mid, l, r);
return getVal(mid + 1, fim, l, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; i++)
v[i] = A[i];
dc(0, n - 1);
}
int Query(int L, int R) {
return getVal(0, n - 1, L, R);
}
//g++ -o secret -O2 grader.cpp secret.cpp
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |