#include <bits/stdc++.h>
#include "secret.h"
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
const int INF = 1e9 + 1;
const int N = 1005;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
x = (x > y ? y : x);
}
int F[N][12];
int mask[N];
int A[N];
void divi(int l, int r, int lev) {
if(l == r) {
return;
}
int rm = (l + r) / 2;
F[rm][lev] = A[rm];
F[rm + 1][lev] = A[rm + 1];
for(int i = rm - 1;i >= l;--i)
F[i][lev] = Secret(A[i], F[i + 1][lev]);
for(int i = rm + 2;i <= r;++i)
F[i][lev] = Secret(A[i], F[i - 1][lev]);
for(int i = rm + 1;i <= r;++i)
mask[i] ^= 1 << lev;
divi(l, rm, lev + 1);
divi(rm + 1, r, lev + 1);
}
void Init(int D, int s[]) {
forn(i, D) A[i] = s[i];
memset(F, 0, sizeof F);
divi(0, D - 1, 0);
}
int Query(int L, int R) {
if(L == R) {
return A[L];
}
int b = __builtin_ctz((mask[L] ^ mask[R]));
return Secret(F[L][b], F[R][b]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
144 ms |
2488 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271. |
2 |
Incorrect |
131 ms |
2420 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376. |
3 |
Incorrect |
134 ms |
2368 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820. |
4 |
Incorrect |
505 ms |
4216 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536. |
5 |
Incorrect |
496 ms |
4292 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838. |
6 |
Incorrect |
540 ms |
4212 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050. |
7 |
Incorrect |
508 ms |
4316 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570. |
8 |
Incorrect |
507 ms |
4312 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264. |
9 |
Incorrect |
518 ms |
4240 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135. |
10 |
Incorrect |
513 ms |
4360 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726. |