#include "secret.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAX = 1004;
map<pii, int> D;
int N, S[MAX];
void DnC1(int L, int R) {
if (L >= R) return;
int mid = (L + R) >> 1;
int pv = -1;
for (int i = mid - 1; i >= L; --i) {
int n = -1;
if (pv == -1) n = Secret(S[i], S[mid]);
else n = Secret(S[i], pv);
pv = D[{i, mid}] = n;
}
pv = -1;
for (int i = mid + 2; i <= R; ++i) {
int n = -1;
if (pv == -1) n = Secret(S[mid], S[i]);
else n = Secret(pv, S[i]);
pv = D[{mid, i}] = n;
}
DnC1(L, mid);
DnC1(mid + 1, R);
}
void Init(int _N, int A[]) {
N = _N;
for (int i = 0; i < N; ++i) S[i] = A[i];
DnC1(0, N - 1);
for (int i = 0; i < N; ++i) D[{i, i}] = A[i];
}
int DnC2(int L, int R, int s, int e) {
if (L >= R) return -1;
int mid = (L + R) >> 1;
if (s <= mid && mid < e) {
int a = D[{s, mid}], b = D[{mid + 1, e}];
return Secret(a, b);
}
if (e <= mid) return DnC2(L, mid, s, e);
else return DnC2(mid + 1, R, s, e);
}
int Query(int L, int R) {
return DnC2(0, N - 1, L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
112 ms |
3044 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 805576266. |
2 |
Incorrect |
101 ms |
2896 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 571476064. |
3 |
Incorrect |
100 ms |
2900 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136730926. |
4 |
Incorrect |
371 ms |
5332 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 870547617. |
5 |
Incorrect |
370 ms |
4948 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 976357712. |
6 |
Incorrect |
388 ms |
4912 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : -1. |
7 |
Incorrect |
366 ms |
4944 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 781793354. |
8 |
Incorrect |
376 ms |
4792 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 499418120. |
9 |
Incorrect |
368 ms |
4808 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277351906. |
10 |
Incorrect |
379 ms |
4948 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 274498057. |