#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int maxn = 1010, maxlog = 15;
int dp[maxlog][maxn], arr[maxn], n;
void divide(int left, int right, int depth)
{
if (left == right)
{
dp[depth][left] = arr[left];
return;
}
int mid = (left + right) / 2;
dp[depth][mid] = arr[mid];
for (int i = mid - 1; i >= left; i --)
{
dp[depth][i] = Secret(arr[i], dp[depth][i + 1]);
///cout << depth << " " << i << " " << arr[i] << " " << dp[depth][i + 1] << endl;
}
dp[depth][mid + 1] = arr[mid + 1];
for (int i = mid + 2; i <= right; i ++)
dp[depth][i] = Secret(arr[i], dp[depth][i - 1]);
divide(left, mid, depth + 1);
divide(mid + 1, right, depth + 1);
}
void Init(int m, int a[])
{
n = m;
for (int i = 0; i < n; i ++)
arr[i] = a[i];
divide(0, n - 1, 1);
}
int Query(int l, int r)
{
int lf = 0, rf = n - 1, depth = 1;
while(true)
{
int mf = (lf + rf) / 2;
if (lf == rf)
{
return dp[depth][lf];
}
if (r <= mf)
{
rf = mf;
depth ++;
continue;
}
if (l > mf)
{
lf = mf + 1;
depth ++;
continue;
}
int ans = Secret(dp[depth][l], dp[depth][r]);
return ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
119 ms |
2364 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271. |
2 |
Incorrect |
125 ms |
2460 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376. |
3 |
Incorrect |
124 ms |
2400 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820. |
4 |
Incorrect |
456 ms |
4316 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536. |
5 |
Incorrect |
458 ms |
4356 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838. |
6 |
Incorrect |
458 ms |
4364 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050. |
7 |
Incorrect |
496 ms |
4380 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570. |
8 |
Incorrect |
478 ms |
4368 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264. |
9 |
Incorrect |
472 ms |
4340 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135. |
10 |
Incorrect |
470 ms |
4392 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726. |