#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1024;
const int max_log = 15;
int n;
int a[maxn];
int precompute[maxn][max_log];
void divide(int depth, int l, int r)
{
if (l == r)
{
precompute[l][depth] = a[l];
return;
}
int mid = (l + r) / 2;
precompute[mid][depth] = a[mid];
for (int i = mid - 1; i >= l; --i)
{
precompute[i][depth] = Secret(precompute[i + 1][depth], a[i]);
}
precompute[mid + 1][depth] = a[mid + 1];
for (int i = mid + 2; i <= r; ++i)
{
precompute[i][depth] = Secret(precompute[i - 1][depth], a[i]);
}
divide(depth + 1, l, mid);
divide(depth + 1, mid + 1, r);
}
void Init(int N, int Arr[])
{
n = N;
for (int i = 0; i < n; ++i)
{
a[i] = Arr[i];
}
divide(0, 0, n - 1);
}
int recurse(int depth, int l, int r, int ql, int qr)
{
//cout << l << ' ' << r << ' ' << ql << ' ' << qr << endl;
if (l == r)
{
return precompute[l][depth];
}
int mid = (l + r) / 2;
if (qr <= mid)
{
return recurse(depth + 1, l, mid, ql, qr);
}
if (ql >= mid + 1)
{
return recurse(depth + 1, mid + 1, r, ql, qr);
}
//cout << "here for " << l << " and " << r << endl;
return Secret(precompute[l][depth], precompute[r][depth]);
}
int Query(int L, int R)
{
int l = L;
int r = R;
//cout << "-------------------------" << endl;
return recurse(0, 0, n - 1, l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
2340 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 54673711. |
2 |
Incorrect |
101 ms |
2384 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 496578817. |
3 |
Incorrect |
111 ms |
2300 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 20078928. |
4 |
Incorrect |
378 ms |
4224 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 316342811. |
5 |
Incorrect |
393 ms |
4336 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 627707150. |
6 |
Incorrect |
380 ms |
4296 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 456183880. |
7 |
Incorrect |
378 ms |
4280 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 673350762. |
8 |
Incorrect |
379 ms |
4340 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 280414344. |
9 |
Incorrect |
379 ms |
4236 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 962084259. |
10 |
Incorrect |
379 ms |
4372 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 878715528. |