# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
908864 | vjudge1 | Secret (JOI14_secret) | C++17 | 426 ms | 4500 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 <iostream>
#include <vector>
#include "secret.h"
using namespace std;
vector<int> v;
int segtree[10000];
void build(int l, int r, int node) {
if(l == r) {
segtree[node] = v[l];
return;
}
int mid = (l+r)/2;
build(l, mid, node*2);
build(mid+1, r, node*2+1);
segtree[node] = Secret(segtree[node*2], segtree[node*2+1]);
}
int que(int l, int r, int tl, int tr, int node) {
if(tl > r || tr < l) {
return -1;
}
if(l <= tl && tr <= r) {
return segtree[node];
}
int mid = (tl+tr)/2;
int a, b;
a = que(l, r, tl, mid, node*2);
b = que(l, r, mid+1, tr, node*2+1);
if(a == -1) {
return b;
}
if(b == -1) {
return a;
}
return Secret(a, b);
}
int lol;
int Query(int L, int R) {
L++;
R++;
return que(L, R, 1, lol, 1);
}
void Init(int N, int A[]) {
lol = N;
v.push_back(0);
for(int i=0; i<N; i++) {
v.push_back(A[i]);
}
build(1, N, 1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |