# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747861 | Markomafko972 | Secret (JOI14_secret) | C++14 | 662 ms | 524288 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;
int a[1005];
int val[1005][1005];
vector<int> v[1005];
int kol = 0;
// 4: 0 1 2 3
void rek(int l, int r) {
if (l+1 == r) {
val[l][l] = a[l];
return;
}
int mid = (l+r-1)/2;
int tren = a[mid-1];
for (int j = mid-2; j >= l; j--) {
if (kol == 8000) assert(0);
tren = Secret(tren, a[j]);
kol++;
if (tren > 1e9) assert(0);
val[j][mid-1] = tren;
}
tren = a[mid];
for (int j = mid+1; j < r; j++) {
if (kol == 8000) assert(0);
tren = Secret(tren, a[j]);
kol++;
if (tren > 1e9) assert(0);
val[mid][j] = tren;
}
rek(l, mid);
rek(mid, r);
}
void Init(int N, int A[]) {
n = N;
memset(val, -1, sizeof val);
for (int i = 0; i < n; i++) {
a[i] = A[i];
val[i][i] = a[i];
}
rek(0, n);
}
int Query(int l, int r) {
if (l == r) return a[l];
for (int i = l; i < r; i++) {
if (val[l][i] != -1 && val[i+1][r] != -1) return Secret(val[l][i], val[i+1][r]);
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |