# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
487182 | Victor | Secret (JOI14_secret) | C++17 | 425 ms | 8204 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 rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const int INF = 1'000'000'007;
int precomp[1001][1001], nums[1001];
int n;
void dnc(int lo, int hi) {
if (lo >= hi) return;
int mid = (lo + hi) / 2;
precomp[mid][mid] = nums[mid];
per(i,lo,mid)precomp[i][mid]=Secret(nums[i], precomp[i+1][mid]);
precomp[mid+1][mid+1] = nums[mid+1];
rep(i,mid+2,hi+1)precomp[mid+1][i]=Secret(nums[i], precomp[mid+1][i-1]);
dnc(lo,mid);
dnc(mid+1,hi);
}
void Init(int N, int A[]) {
memset(precomp,-1,sizeof(precomp));
rep(i, 0, N) nums[i] = A[i];
dnc(0, N - 1);
n = N;
}
int Query(int L, int R) {
if (L == R) return nums[L];
int lo = 0, hi = n - 1;
while (1) {
int mid = (lo + hi) / 2;
if (L <= mid && mid < R) return Secret(precomp[L][mid], precomp[mid+1][R]);
if(R==mid)return precomp[L][mid];
if (R <= mid)
hi = mid;
else
lo = mid + 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |