# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056344 | Minbaev | Secret (JOI14_secret) | C++17 | 263 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"
using namespace std;
const int nmax = 1000 + 5;
using namespace std;
int n, a[nmax];
int tree[nmax << 2];
void build(int id, int l, int r){
if(l == r){
tree[id] = a[l];
return;
}
int mid = (r + l)/2;
build(id *2, l, mid);
build(id *2 + 1, mid + 1, r);
tree[id] = Secret(tree[id *2 ], tree[id * 1 + 1]);
}
int get(int id, int l, int r, int u, int v){
if(l >= u && r <= v) return tree[id];
int mid = (r + l) /2;
if(mid< u) return get(id * 2 + 1, mid + 1, r, u, v);
if(mid + 1 > v) return get(id * 2, l, mid, u, v);
return Secret(get(id* 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v));
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; ++i) a[i] = A[i];
build(1, 0, n - 1);
}
int Query(int l, int r){
return get(1, 0, n - 1, l, r);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |