# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966932 | Perl32 | Secret (JOI14_secret) | C++14 | 389 ms | 4456 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.
//I wrote this code 4 u <3
#include <bits/stdc++.h>
#include <secret.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
constexpr int lg = 11;
constexpr int maxN = 1001;
int dat[lg][maxN];
int a[maxN], msk[maxN];
void divi(int l, int r, int lvl) {
if (l == r) return;
int m = (l + r) >> 1;
dat[lvl][m] = a[m];
for (int i = m - 1; i >= l; --i) dat[lvl][i] = Secret(a[i], dat[lvl][i + 1]);
dat[lvl][m + 1] = a[m + 1];
for (int i = m + 2; i <= r; ++i) dat[lvl][i] = Secret(dat[lvl][i - 1], a[i]);
for (int i = m + 1; i <= r; ++i) msk[i] ^= 1 << lvl;
divi(l, m, lvl + 1);
divi(m + 1, r, lvl + 1);
}
void Init(int N, int A[]) {
for (int i = 0; i < N; ++i) a[i] = A[i];
divi(0, N - 1, 0);
}
int Query(int l, int r) {
if(l == r) return a[l];
int lvl = __builtin_ctz(msk[l] ^ msk[r]);
return Secret(dat[lvl][l], dat[lvl][r]);
}
//signed main(int32_t argc, char *argv[]) {
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
//
//}
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |