#include "secret.h"
int const MAX = 1e3 + 7;
int len;
int data[MAX][MAX];
void rc(int l, int r, int A[])
{
if (l == r)
{
data[l][l] = A[l];
return;
}
int mid = (l + r) / 2;
rc(l, mid, A);
rc(mid+1, r, A);
for (int i = mid-1; i >= 0; --i)
data[i][mid] = Secret(A[i], data[i+1][mid]);
for (int i = mid+2; i < len; ++i)
data[mid+1][i] = Secret(data[mid+1][i-1], A[i]);
return;
}
void Init(int N, int A[]) {
len = N;
rc(0, N-1, A);
}
int query_rc(int l, int r, int p, int q)
{
if (l == r)
return data[l][l];
int mid = (l + r) / 2;
if (mid == q)
return data[p][mid];
if (mid+1 == p)
return data[mid+1][q];
if (p <= mid && mid+1 <= q)
return Secret(data[p][mid], data[mid+1][q]);
if (q < mid)
return query_rc(l, mid, p, q);
return query_rc(mid+1, r, p, q);
}
int Query(int L, int R) {
return query_rc(0, len-1, L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
390 ms |
4544 KB |
Output isn't correct - number of calls to Secret by Init = 259590, maximum number of calls to Secret by Query = 1 |
2 |
Partially correct |
402 ms |
4588 KB |
Output isn't correct - number of calls to Secret by Init = 260610, maximum number of calls to Secret by Query = 1 |
3 |
Partially correct |
392 ms |
4460 KB |
Output isn't correct - number of calls to Secret by Init = 261632, maximum number of calls to Secret by Query = 1 |
4 |
Partially correct |
1471 ms |
8428 KB |
Output isn't correct - number of calls to Secret by Init = 995006, maximum number of calls to Secret by Query = 1 |
5 |
Partially correct |
1487 ms |
8500 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
6 |
Partially correct |
1468 ms |
8496 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
7 |
Partially correct |
1503 ms |
8428 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
1497 ms |
8428 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
1483 ms |
8560 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
1487 ms |
8328 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |