#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
# define nl "\n"
const int maxn = 1e3 + 3;
int tl[10][maxn];
int tr[10][maxn];
int a[maxn], n, ans;
void doit (int l, int r, int d) {
if (l >= r) return;
// cout << "vot " << l << ' ' << r << ' ' << d << '\n';
int mid = (l + r) >> 1;
tl[d][mid] = a[mid];
for (int i = mid - 1; i >= l; --i) {
tl[d][i] = Secret(a[i], tl[d][i + 1]);
}
// cout << "tl side" << nl;
// for (int i = mid; i >= l; --i) {
// cout << tl[d][i] << ' ';
// }
// cout << nl;
tr[d][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; ++i) {
tr[d][i] = Secret(a[i], tr[d][i - 1]);
}
// cout << "tr side" << nl;
// for (int i = mid + 1; i <= r; ++i) {
// cout << tr[d][i] << ' ';
// }
// cout << nl;
doit(l, mid, d + 1);
doit(mid + 1, r, d + 1);
}
void solve (int L, int R, int l, int r, int d) {
if (l >= r) {
return;
}
int mid = (l + r) >> 1;
if (l <= L && L <= mid && mid + 1 <= R && R <= r) {
ans = Secret(tl[d][L], tr[d][R]);
return;
}
solve (L, R, l, mid, d + 1);
solve (L, R, mid + 1, r, d + 1);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < N; ++i) {
a[i] = A[i];
}
doit (0, n - 1, 1);
}
int Query(int L, int R) {
if (L == R) {
return a[L];
}
ans = 0;
solve (L, R, 0, n - 1, 1);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
2404 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271. |
2 |
Incorrect |
102 ms |
2508 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376. |
3 |
Incorrect |
103 ms |
2416 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820. |
4 |
Incorrect |
374 ms |
4440 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536. |
5 |
Incorrect |
377 ms |
4432 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838. |
6 |
Incorrect |
379 ms |
4356 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050. |
7 |
Incorrect |
378 ms |
4396 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570. |
8 |
Incorrect |
379 ms |
4508 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264. |
9 |
Incorrect |
379 ms |
4412 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135. |
10 |
Incorrect |
376 ms |
4336 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726. |