# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
606140 | kawaii | Secret (JOI14_secret) | C++14 | 764 ms | 8228 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;
int n, a[1005], pre[1005][1005];
void dnc(int l, int r){
if(l == r) return;
int mid = l + r >> 1;
dnc(l, mid); dnc(mid + 1, r);
for(int i = mid - 1; i >= l; i--) pre[i][mid] = pre[mid][i] = Secret(a[i], pre[i + 1][mid]);
for(int i = mid + 1; i <= r; i++) pre[mid][i] = pre[i][mid] = Secret(pre[mid][i - 1], a[i]);
}
void Init(int N, int A[]){
for(int i = 1; i <= N; i++) a[i] = A[i - 1], pre[i][i] = a[i];
n = N;
dnc(1, n);
}
int solve(int l, int r, int lf, int rt){
if(l == r) return a[l];
int mid = l + r >> 1;
if(lf <= mid && mid <= rt){
if(lf == mid) return pre[mid][rt];
if(rt == mid) return pre[lf][mid];
return Secret(pre[lf][mid - 1], pre[mid][rt]);
}
if(rt < mid) return solve(l, mid, lf, rt);
else return solve(mid + 1, r, lf, rt);
}
int Query(int L, int R){
L++; R++;
return solve(1, n, L, R);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |