#include <bits/stdc++.h>
#include "secret.h"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
using namespace std;
int n, a[1005], cnt;
vector <int> ops[4005];
//int Secret(int X, int Y) {
// /// program's
// ++cnt;
// return X^Y;
//}
void build(int id=1, int l=0, int r=n-1) {
if(l == r) {
ops[id] = {a[l]};
return;
}
int mid = (l + r) >> 1;
ops[id] = {a[mid]};
FORD(i, mid-1, l) ops[id].eb(Secret(ops[id].back(), a[i]));
reverse(all(ops[id]));
ops[id].eb(a[mid+1]);
FOR(i, mid+2, r) ops[id].eb(Secret(ops[id].back(), a[i]));
build(id<<1, l, mid);
build(id<<1|1, mid+1, r);
}
void Init(int N, int A[]) {
n = N;
FOR(i, 0, N-1) {
a[i] = A[i];
}
build();
}
int get(int L, int R, int id=1, int l=0, int r=n-1) {
int mid = (l+r) >> 1;
if(L==mid) return ops[id][L-l];
if(R==mid) return ops[id][R-l];
if(L<=mid && mid+1<=R) return Secret(ops[id][L-l], ops[id][R-l]);
if(R<mid) return get(L, R, id<<1, l, mid);
return get(L, R, id<<1|1, mid+1, r);
}
int Query(int L, int R) {
return get(L, R);
}
//int main() {
// int b[] = {1,2,3,4,5,6,7,8};
// Init(8, b);
// cout<<cnt<<'\n';
// cout<<Query(2,2)<<'\n';
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
2640 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
66 ms |
2640 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
77 ms |
2588 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
257 ms |
4520 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
273 ms |
4436 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
257 ms |
4688 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 439006153. |
7 |
Incorrect |
268 ms |
4632 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
306 ms |
4628 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
256 ms |
4500 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
258 ms |
4432 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |