#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e3;
int tree[2][4*nax+5];
int a[nax+5];
int n;
void build(int x, int l=0, int r=n-1, int idx=1){
if (l == r) {
tree[x][idx] = a[l+x];
} else {
int m = (l+r)>>1;
build(x,l,m,idx<<1);
build(x,m+1,r,idx<<1|1);
tree[x][idx] = Secret(tree[x][idx<<1], tree[x][idx<<1|1]);
}
}
int get(int x, int fr, int to, int l=0, int r=n-1, int idx=1) {
if (fr <= l && r <= to) return tree[x][idx];
else {
int m = (l+r)>>1;
if (fr > m) {
return get(x, fr, to, m+1, r, idx<<1|1);
} else if (to <= m) {
return get(x, fr, to, l, m, idx<<1);
} else {
//cerr << x << " " << fr << " " << to << " "<<l<<" " << r<<endl;
return Secret(get(x, fr, to, m+1, r, idx<<1|1), get(x, fr, to, l, m, idx<<1));
}
}
}
void Init(int N, int A[]) {
n=N;
for(int i=0; i<N; i++) a[i] = A[i];
build(0); //build(1);
}
int Query(int L, int R) {
return get(0,L,R);
return get(L%2,L-(L%2),R-(L%2));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
108 ms |
2284 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 307520343. |
2 |
Incorrect |
112 ms |
2296 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 42053665. |
3 |
Incorrect |
112 ms |
2280 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 563314998. |
4 |
Incorrect |
425 ms |
4412 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 587940447. |
5 |
Incorrect |
416 ms |
4224 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 778589442. |
6 |
Incorrect |
434 ms |
4272 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 52647746. |
7 |
Incorrect |
430 ms |
4316 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 34090009. |
8 |
Incorrect |
428 ms |
4268 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 337773832. |
9 |
Incorrect |
436 ms |
4296 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 962070828. |
10 |
Incorrect |
419 ms |
4236 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 873597508. |