# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
683885 | amukkalir | Secret (JOI14_secret) | C++17 | 436 ms | 4412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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));
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |