#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int n;
vector<vector<int>> t(15, vector<int>(1005));
void calc(int L, int R, int dep, int A[]) {
assert(dep < 15);
if (L == R) {
t[dep][L] = A[L];
return;
}
int m = (L + R) / 2;
t[dep][m] = A[m];
for (int i = m - 1; i >= L; i--) {
t[dep][i] = Secret(A[i], t[dep][i + 1]);
}
t[dep][m + 1] = A[m + 1];
for (int i = m + 2; i <= R; i++) {
t[dep][i] = Secret(A[i], t[dep][i - 1]);
}
calc(L, m, dep + 1, A);
calc(m + 1, R, dep + 1, A);
}
void Init(int N, int A[]) {
n = N;
calc(0, n - 1, 0, A);
}
int get(int L, int R, int qL, int qR, int dep) {
assert(dep < 15);
assert(L <= qL && qR <= R);
if (L == R) {
return t[dep][L];
}
int m = (L + R) / 2;
if (qL <= m && m + 1 <= qR) {
return Secret(t[dep][qL], t[dep][qR]);
} else if (qR <= m) {
return get(L, m, qL, qR, dep + 1);
}
return get(m + 1, R, qL, qR, dep + 1);
}
int Query(int L, int R) {
return get(0, n - 1, L, R, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
121 ms |
2388 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271. |
2 |
Incorrect |
113 ms |
2380 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376. |
3 |
Incorrect |
121 ms |
2380 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820. |
4 |
Incorrect |
459 ms |
4416 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536. |
5 |
Incorrect |
445 ms |
4332 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838. |
6 |
Incorrect |
458 ms |
4244 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050. |
7 |
Incorrect |
461 ms |
4232 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570. |
8 |
Incorrect |
464 ms |
4272 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264. |
9 |
Incorrect |
454 ms |
4256 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135. |
10 |
Incorrect |
472 ms |
4320 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726. |