#include "secret.h"
#include <map>
#include <utility>
using namespace std;
typedef pair<int, int> ip;
int a[1001], n;
map<ip, int> d;
int qry(int l, int r, int L, int R) {
if (L == R) return a[L];
int mid = (l + r) / 2;
if (R < mid) return qry(l, mid, L, R);
else if (L >= mid) return qry(mid, r, L, R);
else {
return Secret(d[ip(L, mid - 1)], d[ip(mid, R)]);
}
}
int Query(int L, int R) {
return qry(0, n, L, R);
}
void go(int l, int r) {
if (l + 1 == r) return;
int mid = (l + r) / 2;
int cur = a[mid - 1];
for (int i = mid - 2; i >= 0; i--) {
cur = Secret(a[i], cur);
d[ip(i, mid - 1)] = cur;
}
cur = a[mid];
for (int i = mid + 1; i < n; i++) {
cur = Secret(cur, a[i]);
d[ip(mid, i)] = cur;
}
go(l, mid);
go(mid, r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++) {
a[i] = A[i];
d[ip(i, i)] = a[i];
}
go(0, n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
552 ms |
10600 KB |
Output isn't correct - number of calls to Secret by Init = 259590, maximum number of calls to Secret by Query = 1 |
2 |
Incorrect |
571 ms |
10764 KB |
Output isn't correct - number of calls to Secret by Init = 260610, maximum number of calls to Secret by Query = 1 |
3 |
Incorrect |
548 ms |
10932 KB |
Output isn't correct - number of calls to Secret by Init = 261632, maximum number of calls to Secret by Query = 1 |
4 |
Incorrect |
2271 ms |
35744 KB |
Output isn't correct - number of calls to Secret by Init = 995006, maximum number of calls to Secret by Query = 1 |
5 |
Incorrect |
2242 ms |
35920 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
6 |
Incorrect |
2158 ms |
35920 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
7 |
Incorrect |
2126 ms |
36140 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
8 |
Incorrect |
2328 ms |
36228 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
9 |
Incorrect |
2330 ms |
36228 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |
10 |
Incorrect |
2188 ms |
36228 KB |
Output isn't correct - number of calls to Secret by Init = 997002, maximum number of calls to Secret by Query = 1 |