#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
struct Tree {
vector<vector<int>> left, right;
int n;
void init(int n, const vector<int>& data) {
this->n = n;
left.resize(4 * n + 5);
right.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[l];
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);
};
dfs(dfs, 1, 0, n - 1);
}
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
112 ms |
2448 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
110 ms |
2428 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
111 ms |
2444 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
410 ms |
4468 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
420 ms |
4576 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Execution timed out |
20019 ms |
4472 KB |
Time limit exceeded |
7 |
Incorrect |
409 ms |
4584 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
421 ms |
4556 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
416 ms |
4528 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
415 ms |
4460 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |