#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
constexpr int NMAX = 1005;
int n;
int V[NMAX];
int ans[NMAX][NMAX];
void Precalculare (int Left, int Right) {
if (Left >= Right) return;
int mij = (Left + Right) / 2;
ans[mij][mij] = V[mij];
for (int i = mij-1; i >= Left; -- i )
ans[i][mij] = Secret(V[i], ans[i+1][mij]);
ans[mij+1][mij+1] = V[mij+1];
for (int i = mij+2; i <= Right; ++ i )
ans[mij+1][i] = Secret(ans[mij+1][i-1], V[i]);
Precalculare(Left, mij);
Precalculare(mij+1, Right);
}
void Init (int N, int A[]) {
n = N;
for (int i = 1; i <= N; ++ i )
V[i] = A[i-1];
Precalculare(1, N);
}
int Answer (int st, int dr, int qa, int qb) {
int mij = (st + dr) / 2;
if (qa <= mij && mij <= qb)
return Secret(ans[qa][mij], ans[mij+1][qb]);
if (qb < mij)
return Answer(st, mij-1, qa, qb);
return Answer(mij+1, dr, qa, qb);
}
int Query(int L, int R) {
return Answer(1, n, L+1, R+1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
4400 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042. |
2 |
Incorrect |
113 ms |
4372 KB |
Wrong Answer: Query(210, 211) - expected : 558550312, actual : 558532904. |
3 |
Incorrect |
117 ms |
4436 KB |
Wrong Answer: Query(67, 224) - expected : 202440844, actual : 536870912. |
4 |
Incorrect |
425 ms |
8320 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : 536870912. |
5 |
Incorrect |
420 ms |
8260 KB |
Wrong Answer: Query(263, 292) - expected : 653448456, actual : 536870912. |
6 |
Incorrect |
462 ms |
8260 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241. |
7 |
Correct |
438 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
452 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
443 ms |
8248 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
449 ms |
8332 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |