# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977789 | NoLove | Secret (JOI14_secret) | C++14 | 395 ms | 4516 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"
/**
* author : Lăng Trọng Đạt
* created: 08-05-2024
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
// #define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 1e3 + 5;
int g[MAXN];
int n;
int mask[MAXN];
int dat[12][MAXN];
void build(int l, int r, int lv) {
if (l != r) {
int m = (l + r) / 2;
dat[lv][m] = g[m];
for (int i = m - 1; i >= l; i--) {
dat[lv][i] = Secret(g[i], dat[lv][i + 1]);
}
dat[lv][m + 1] = g[m + 1];
mask[m + 1] ^= 1 << lv;
for (int i = m + 2; i <= r; i++) {
dat[lv][i] = Secret(dat[lv][i - 1], g[i]);
mask[i] ^= 1 << lv;
}
build(l, m, lv + 1);
build(m + 1, r, lv + 1);
}
}
void Init(int N, int A[]) {
n = N;
FOR(i, 0, n - 1) g[i] = A[i];
build(0, n - 1, 0);
}
int Query(int L, int R) {
if (L == R) return g[L];
else {
int bit = __builtin_ctz(mask[L] ^ mask[R]);
return Secret(dat[bit][L], dat[bit][R]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |