#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1005];
int dp[10][1005];
void calc(int st, int dr, int p)
{
if(st >= dr)
return;
int mij = (st + dr)/2;
//cout<<st<<' '<<dr<<'\n';
dp[p][mij-1] = a[mij-1];
for(int i=mij-2; i>=st; i--)
dp[p][i] = Secret(dp[p][i+1], a[i]);
dp[p][mij] = a[mij];
for(int i=mij+1; i<=dr; i++)
dp[p][i] = Secret(dp[p][i-1], a[i]);
calc(st, mij-1, p+1);
calc(mij+1, dr, p+1);
}
int query(int stt, int drt, int st, int dr, int p)
{
int mij = (st+dr)/2;
if(drt < mij)
return query(stt, drt, st, mij-1, p+1);
if(stt > mij)
return query(stt, drt, mij+1, dr, p+1);
if(stt == mij)
return dp[p][drt];
else
return Secret(dp[p][stt], dp[p][drt]);
}
void Init(int N, int A[])
{
n = N;
for(int i=0;i<n;i++)
a[i] = A[i];
//cout<<"build\n";
calc(0, n-1, 1);
}
int Query(int l, int r)
{
if(l == r)
return a[l];
return query(l, r, 0, n-1, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
114 ms |
2380 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 50471211. |
2 |
Incorrect |
118 ms |
2484 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 29530216. |
3 |
Incorrect |
115 ms |
2452 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982. |
4 |
Incorrect |
431 ms |
4384 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 858309235. |
5 |
Incorrect |
434 ms |
4428 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 602966360. |
6 |
Incorrect |
431 ms |
4364 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 313045306. |
7 |
Incorrect |
435 ms |
4528 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 578359305. |
8 |
Incorrect |
437 ms |
4428 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 633393600. |
9 |
Incorrect |
433 ms |
4308 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 148126725. |
10 |
Incorrect |
434 ms |
4352 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 275769990. |