#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int res[1010][1010];
int tab[1010];
int N;
void cnt(int l, int r) {
if(l > r) {
return;
}
if(l == r) {
res[l][l] = tab[l];
return;
}
int mid = (l + r) / 2;
res[mid][mid] = tab[mid];
res[mid][mid - 1] = tab[mid - 1];
for(int i = mid - 2; i >= l; i--) {
res[mid][i] = Secret(tab[i], res[mid][i + 1]);
}
for(int i = mid + 1; i <= r; i++) {
res[mid][i] = Secret(res[mid][i - 1], tab[i]);
}
cnt(l, mid - 1);
cnt(mid + 1, r);
}
void Init(int n, int a[]) {
N = n;
for(int i = 0; i < n; i++) {
tab[i] = a[i];
}
cnt(0, n - 1);
}
int rek(int l, int r, int L, int R) {
if(l == r) {
return tab[l];
}
int mid = (L + R) / 2;
if(l <= mid && mid <= r) {
return Secret(res[mid][l], res[mid][r]);
}
if(l > mid) {
return rek(l, r, mid + 1, R);
}
return rek(l, r, L, mid - 1);
}
int Query(int l, int r) {
return rek(l, r, 0, N - 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
4320 KB |
Wrong Answer: Query(255, 409) - expected : 307522235, actual : 38999632. |
2 |
Incorrect |
121 ms |
4316 KB |
Wrong Answer: Query(127, 153) - expected : 342921603, actual : 542288066. |
3 |
Incorrect |
151 ms |
4300 KB |
Wrong Answer: Query(139, 140) - expected : 532639920, actual : 782809598. |
4 |
Incorrect |
453 ms |
8140 KB |
Wrong Answer: Query(374, 396) - expected : 402362963, actual : 342036658. |
5 |
Incorrect |
451 ms |
8148 KB |
Wrong Answer: Query(937, 999) - expected : 615241818, actual : 827956544. |
6 |
Incorrect |
450 ms |
8140 KB |
Wrong Answer: Query(653, 654) - expected : 227441904, actual : 898455697. |
7 |
Correct |
536 ms |
8204 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
470 ms |
8216 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
509 ms |
8388 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
503 ms |
8212 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |