# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29096 | PrOAhMeT | Secret (JOI14_secret) | C++14 | 659 ms | 9924 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 mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
int a[1001][1001],size;
void dac(int l,int r,int v[]) {
if(l>r)
return;
if(l==r) {
a[l][l]=v[l];
return;
}
int md=(l+r)/2;
a[md][md]=v[md];
for(int i=md-1;i>=l;--i) {
a[i][md]=Secret(v[i],a[i+1][md]);
}
if(md!=r) {
a[md+1][md+1]=v[md+1];
for(int i=md+2;i<=r;++i){
a[md+1][i]=Secret(a[md+1][i-1],v[i]);
}
}
dac(l,md-1,v);
dac(md+1,r,v);
}
int solve(int l,int r,int ll,int rr) {
int md=(l+r)/2;
if(ll<=md&&rr>=md) {
if(rr==md)
return a[ll][md];
else return Secret(a[ll][md],a[md+1][rr]);
}
if(rr<md)
return solve(l,md-1,ll,rr);
else return solve(md+1,r,ll,rr);
}
void Init(int N, int A[]) {
size=N;
dac(0,N-1,A);
}
int Query(int L, int R) {
return solve(0,size-1,L,R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |