# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915934 | OAleksa | Secret (JOI14_secret) | C++14 | 400 ms | 8440 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>
//vaso daso gej
using namespace std;
#define f first
#define s second
const int N = 1010;
int n, a[N], val[N][N];
void solve(int L, int R) {
if (R - L <= 1)
return;
int mid = (L + R) / 2;
for (int i = mid - 1;i >= L;i--)
val[i][mid] = Secret(a[i], val[i + 1][mid]);
for (int i = mid + 2;i <= R;i++)
val[mid + 1][i] = Secret(val[mid + 1][i - 1], a[i]);
solve(L, mid);
solve(mid + 1, R);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0;i < n;i++) {
a[i] = A[i];
val[i][i] = a[i];
}
solve(0, n - 1);
}
int Query(int L, int R) {
if (L == R)
return a[L];
else if (R == L + 1)
return Secret(a[L], a[R]);
for (int i = L;i <= R;i++) {
for (int j = i + 1;j <= R;j++) {
if (val[i][j - 1] > 0 && val[j][R])
return Secret(val[i][j - 1], val[j][R]);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |