# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1085796 |
2024-09-08T17:41:01 Z |
f0rizen |
Secret (JOI14_secret) |
C++17 |
|
336 ms |
4532 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;
const int lg = 10;
int *a;
vector<int> st[lg];
vector<int> mask;
void Init(int N, int A[]) {
a = A;
for (int i = 0; i < lg; ++i) {
st[i].resize(N);
}
mask.resize(N);
auto build = [&](auto build, int l, int r, int k) -> void {
if (l == r) {
return;
}
int mid = (l + r) / 2;
st[k][mid] = A[mid];
for (int i = mid - 1; i >= l; --i) {
st[k][i] = Secret(A[i], st[k][i + 1]);
}
st[k][mid + 1] = A[mid + 1];
for (int i = mid + 2; i <= r; ++i) {
st[k][i] = Secret(st[k][i - 1], A[i]);
}
for (int i = mid + 1; i <= r; ++i) {
mask[i] ^= (1 << k);
}
build(build, l, mid, k + 1);
build(build, mid + 1, r, k + 1);
};
build(build, 0, N - 1, 0);
}
int Query(int L, int R) {
if (L == R) {
return a[L];
}
int k = __builtin_ctz(mask[L] ^ mask[R]);
return Secret(st[k][L], st[k][R]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
2576 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
87 ms |
2396 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
86 ms |
2388 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
314 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
327 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
314 ms |
4300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
307 ms |
4324 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
336 ms |
4532 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
308 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
321 ms |
4352 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |