#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int MAXN = 1e3 + 5;
int n, A[MAXN], DP[MAXN][MAXN];
void Build(int s = 0, int e = n) {
if (e - s < 2) {
DP[s][e] = A[s];
return;
}
int md = (s + e) >> 1;
Build(s, md), Build(md, e);
DP[md - 1][md] = A[md - 1];
for (int i = md - 2; i >= s; i--) DP[i][md] = Secret(A[i], DP[i + 1][md]);
DP[md][md + 1] = A[md];
for (int i = md + 2; i <= e; i++) DP[md][i] = Secret(DP[md][i - 1], A[i - 1]);
}
int Get(int l, int r, int s = 0, int e = n) {
int md = (s + e) >> 1;
if (r < md) return Get(l, r, s, md);
if (l > md) return Get(l, r, md, e);
return Secret(DP[l][md], DP[md][r]);
}
void Init(int _n, int _A[]) {
n = _n;
for (int i = 0; i < n; i++) A[i] = _A[i];
Build();
}
int Query(int l, int r) {
return Get(l, r + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
138 ms |
4600 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 34031537. |
2 |
Incorrect |
141 ms |
4580 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 173115656. |
3 |
Incorrect |
135 ms |
4472 KB |
Wrong Answer: Query(128, 153) - expected : 959658850, actual : 422787426. |
4 |
Incorrect |
495 ms |
8316 KB |
Wrong Answer: Query(374, 396) - expected : 402362963, actual : 939229779. |
5 |
Incorrect |
556 ms |
8376 KB |
Wrong Answer: Query(584, 592) - expected : 111053842, actual : 110791698. |
6 |
Incorrect |
517 ms |
8324 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241. |
7 |
Correct |
536 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
543 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
539 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
518 ms |
8452 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |