#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
struct Tree {
vector<vector<int>> left, right;
vector<pii> range_rep;
int n;
void init(int n, const vector<int>& data) {
this->n = n;
left.resize(4 * n + 5);
right.resize(4 * n + 5);
range_rep.resize(4 * n + 5);
auto dfs = [&](auto dfs, int z, int l, int r) -> void {
int m = (l + r) >> 1;
left[z].resize(m - l + 1);
right[z].resize(r - m);
if (l == r) {
left[z][0] = data[z];
return;
}
left[z][0] = data[m];
for (int i = m - 1, idx = 1; i >= l; i--, idx++) {
left[z][idx] = Secret(left[z][idx - 1], data[i]);
}
right[z][0] = data[m + 1];
for (int i = m + 2, idx = 1; i <= r; i++, idx++) {
right[z][idx] = Secret(right[z][idx - 1], data[i]);
}
dfs(dfs, 2 * z, l, m);
dfs(dfs, 2 * z + 1, m + 1, r);
};
}
int query(int z, int l, int r, int ql, int qr) {
int m = (l + r) >> 1;
if (qr <= m) return query(2 * z, l, m, ql, qr);
if (ql >= m + 1) return query(2 * z + 1, m + 1, r, ql, qr);
int idx1 = m - ql, idx2 = qr - (m + 1);
return Secret(left[z][idx1], right[z][idx2]);
}
int query(int ql, int qr) { return query(1, 0, n - 1, ql, qr); }
} tree;
void Init(int N, int A[]) {
vector<int> a(N);
for (int i = 0; i < N; i++)
a[i] = A[i];
tree.init(N, a);
}
int Query(int L, int R) {
return tree.query(L, R);
}
Compilation message
secret.cpp: In member function 'void Tree::init(int, const std::vector<int>&)':
secret.cpp:18:8: warning: variable 'dfs' set but not used [-Wunused-but-set-variable]
18 | auto dfs = [&](auto dfs, int z, int l, int r) -> void {
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
111 ms |
4820 KB |
Execution killed with signal 11 |
2 |
Runtime error |
114 ms |
4936 KB |
Execution killed with signal 11 |
3 |
Runtime error |
112 ms |
4836 KB |
Execution killed with signal 11 |
4 |
Runtime error |
422 ms |
9088 KB |
Execution killed with signal 11 |
5 |
Runtime error |
416 ms |
8964 KB |
Execution killed with signal 11 |
6 |
Execution timed out |
20071 ms |
4612 KB |
Time limit exceeded |
7 |
Runtime error |
432 ms |
8960 KB |
Execution killed with signal 11 |
8 |
Runtime error |
428 ms |
9016 KB |
Execution killed with signal 11 |
9 |
Runtime error |
421 ms |
9004 KB |
Execution killed with signal 11 |
10 |
Runtime error |
413 ms |
8924 KB |
Execution killed with signal 11 |