# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434938 | keta_tsimakuridze | Secret (JOI14_secret) | C++14 | 520 ms | 8388 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 x[1005][1005],a[1005],n;
void solve(int l,int r) {
if(l==r) return;
int mid = (l+r)/2;
for(int i=l;i<mid;i++) {
x[i][mid] = Secret(a[i],a[mid]);
}
x[mid][mid] = a[mid];
for(int i=mid+2;i<=r;i++) {
x[mid+1][i] = Secret(a[i],a[mid+1]);
}
x[mid+1][mid+1]=a[mid+1];
solve(l,mid);
solve(mid+1,r);
}
void Init(int m, int A[]) {
//Secret(0, 1000000000);
n = m;
for(int i = n; i>0; i--) {
a[i] = A[i-1];
}
solve(1,n);
}
int Query(int L, int R) {
L++; R++;
if(L == R) return a[L];
int l = 1, r = n;
while(true) {
int mid = (l+r)/2;
if(R<=mid) {
r = mid - 1;
continue;
}
if(L>mid) {
l = mid ;
continue;
}
return Secret(x[L][mid],x[mid+1][R]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |